-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
133 lines (115 loc) · 4.06 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
cmake_minimum_required(VERSION 3.5)
project(ai_debate_client)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Add more warnings than -Wall.
# These enable warnings in VSCode as well.
add_definitions("-Wreorder -Wunused -Wparentheses -Wimplicit-fallthrough -Wreturn-type -Wuninitialized -Winit-self")
# We need this options for generating compile_commands.json file
# It's required for clang static analyzer and autocompletion tools based on clang
# PVS uses it too
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# In addition to the above, to enable the unused includes diagnostic in VSCode,
# create the following .clangd file in the project root directory:
# Diagnostics:
# UnusedIncludes: Strict
# The main source file.
set(MAIN_SOURCE
src/main.cpp
)
# Source files without the main file.
set(APP_SOURCES
src/chat.cpp
src/api_client/api_client.cpp
src/api_client/api_stream_handler.cpp
src/api_client/gpt_chunk_processor.cpp
src/api_client/gpt_request_maker.cpp
src/api_client/claude_chunk_processor.cpp
src/api_client/claude_request_maker.cpp
src/api_client/gemini_chunk_processor.cpp
src/api_client/gemini_request_maker.cpp
src/util/stacktrace.cpp
src/util/json_printer.cpp
src/util/string_cleaner.cpp
)
# Library files.
set(DEP_LIBS
cpr::cpr
nlohmann_json::nlohmann_json
cpptrace::cpptrace
expected
)
# For each included library, the git command is given for checking the tags.
# Note that the git command returns them in lexicographical order. So, for
# example, v1.9.0 comes after v1.10.0 because as strings "v1.9" is sorted after
# "v1.1". However, these tags represent semantic versioning, which means that
# each part of the version tag is a separate number. So, v1.10.0 is laaer
# version than v1.9.0.
include(FetchContent)
# Include expected for error handling.
# To check the tags,
# $ git ls-remote --tags https://github.com/TartanLlama/expected.git
FetchContent_Declare(
expected
GIT_REPOSITORY https://github.com/TartanLlama/expected.git
GIT_TAG v1.1.0 # origin/master
)
FetchContent_MakeAvailable(expected)
message(STATUS "expected_SOURCE_DIR: ${expected_SOURCE_DIR}")
include_directories(${expected_SOURCE_DIR})
# Include cpptrace for better stack traces.
# To check the tags,
# $ git ls-remote --tags https://github.com/jeremy-rifkin/cpptrace.git
FetchContent_Declare(
cpptrace
GIT_REPOSITORY https://github.com/jeremy-rifkin/cpptrace.git
GIT_TAG v0.5.2 # main
)
FetchContent_MakeAvailable(cpptrace)
message(STATUS "cpptrace_SOURCE_DIR: ${cpptrace_SOURCE_DIR}")
include_directories(${cpptrace_SOURCE_DIR})
# Include cpr for HTTP requests.
# To check the tags,
# $ git ls-remote --tags https://github.com/libcpr/cpr.git
include(FetchContent)
FetchContent_Declare(
cpr
GIT_REPOSITORY https://github.com/libcpr/cpr.git
GIT_TAG 1.10.5
)
FetchContent_MakeAvailable(cpr)
message(STATUS "cpr_SOURCE_DIR: ${cpr_SOURCE_DIR}")
include_directories(${cpr_SOURCE_DIR})
# Include nlohmann/json for JSON parsing.
# To check the tags,
# $ git ls-remote --tags https://github.com/nlohmann/json.git
FetchContent_Declare(
json
URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz
)
FetchContent_MakeAvailable(json)
message(STATUS "json_SOURCE_DIR: ${json_SOURCE_DIR}")
include_directories(${json_SOURCE_DIR})
# Include doctest for testing.
# To check the tags,
# $ git ls-remote --tags https://github.com/onqtam/doctest
FetchContent_Declare(
doctest
GIT_REPOSITORY "https://github.com/onqtam/doctest"
GIT_TAG v2.4.9
)
FetchContent_MakeAvailable(doctest)
message(STATUS "doctest_SOURCE_DIR: ${doctest_SOURCE_DIR}")
include_directories(${doctest_SOURCE_DIR})
# Avoid `file(GLOB SOURCES src/*.cpp)` because it won't pick up new files
# automatically.
add_executable(ai_debate_app ${MAIN_SOURCE} ${APP_SOURCES})
target_link_libraries(ai_debate_app PRIVATE ${DEP_LIBS})
# Define the tests.
set(TEST_SOURCES
tests/chunk_processor_test.cpp
tests/api_client_test.cpp
tests/string_cleaner_test.cpp
)
add_executable(ai_debate_tests ${APP_SOURCES} ${TEST_SOURCES})
target_link_libraries(ai_debate_tests PRIVATE ${DEP_LIBS} doctest)