-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
177 lines (158 loc) · 4.01 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# cmake -B build . && cmake --build build -j
cmake_minimum_required(VERSION 3.24)
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
project(Blog)
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz
)
FetchContent_Declare(
cxxopts
GIT_REPOSITORY https://github.com/jarro2783/cxxopts.git
GIT_TAG v3.1.1
)
FetchContent_Declare(
httplib
GIT_REPOSITORY https://github.com/yhirose/cpp-httplib.git
GIT_TAG v0.18.0
)
FetchContent_Declare(
ryml
GIT_REPOSITORY https://github.com/biojppm/rapidyaml.git
GIT_TAG
GIT_SHALLOW FALSE # ensure submodules are checked out
)
FetchContent_Declare(
json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.11.3
)
FetchContent_Declare(
inja
GIT_REPOSITORY https://github.com/pantor/inja.git
GIT_TAG main
)
include_directories(${json_SOURCE_DIR}/single_include)
set(INJA_USE_EMBEDDED_JSON FALSE)
set(INJA_BUILD_TESTS FALSE)
set(BUILD_BENCHMARK FALSE)
FetchContent_Declare(
spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog.git
GIT_TAG v1.12.0
)
FetchContent_Declare(
cmark
GIT_REPOSITORY https://github.com/commonmark/cmark.git
GIT_TAG 0.31.1
)
set(SPDLOG_USE_STD_FORMAT ON)
FetchContent_MakeAvailable(json inja httplib cxxopts googletest ryml spdlog cmark)
unset(BUILD_BENCHMARK)
find_package(CURL REQUIRED)
find_package(SQLite3 REQUIRED)
# find_package(cmark REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(libmagic REQUIRED libmagic)
FetchContent_Declare(
# This name can be anything but “cryptopp”.
cryptopp_cmake
GIT_REPOSITORY https://github.com/abdes/cryptopp-cmake.git
)
set(CRYPTOPP_BUILD_TESTING OFF)
FetchContent_MakeAvailable(cryptopp_cmake)
set(SOURCE_FILES
src/app.cpp
src/app.hpp
src/attachment.cpp
src/attachment.hpp
src/auth.cpp
src/auth.hpp
src/config.cpp
src/config.hpp
src/data.cpp
src/data.hpp
src/database.cpp
src/database.hpp
src/hash.cpp
src/hash.hpp
src/error.hpp
src/exec.cpp
src/exec.hpp
src/http_client.cpp
src/http_client.hpp
src/post.cpp
src/post.hpp
src/post_rendering.cpp
src/post_rendering.hpp
src/url.cpp
src/url.hpp
src/utils.hpp
src/attachment.hpp
src/legacy-migration.hpp
src/theme.cpp
src/theme.hpp
)
set(LIBS
cxxopts
httplib
spdlog::spdlog
ryml::ryml
${CURL_LIBRARIES}
${SQLite3_LIBRARIES}
cryptopp::cryptopp
${libmagic_LIBRARIES}
cmark
)
set(INCLUDES
${CURL_INCLUDE_DIR}
${json_SOURCE_DIR}/single_include
${inja_SOURCE_DIR}/single_include/inja
${SQLite3_INCLUDE_DIRS}
${libmagic_INCLUDE_DIRS}
)
add_executable(planck-blog ${SOURCE_FILES} src/main.cpp)
set_property(TARGET planck-blog PROPERTY CXX_STANDARD 23)
set_property(TARGET planck-blog PROPERTY COMPILE_WARNING_AS_ERROR TRUE)
target_compile_options(planck-blog PRIVATE -Wall -Wextra -Wpedantic)
target_include_directories(planck-blog PRIVATE ${INCLUDES})
target_link_libraries(planck-blog PRIVATE ${LIBS})
set(TEST_FILES
src/app_test.cpp
src/attachment_test.cpp
src/auth_mock.hpp
src/auth_test.cpp
src/data_mock.hpp
src/data_test.cpp
src/database_test.cpp
src/exec_test.cpp
src/hash_test.cpp
src/hash_mock.hpp
src/http_client_mock.hpp
src/http_client_test.cpp
src/post_rendering_test.cpp
src/test_utils.hpp
src/url_test.cpp
src/utils_test.cpp
)
# ctest --test-dir build
add_executable(planck-blog_test ${SOURCE_FILES} ${TEST_FILES})
set_property(TARGET planck-blog_test PROPERTY CXX_STANDARD 23)
set_property(TARGET planck-blog_test PROPERTY COMPILE_WARNING_AS_ERROR TRUE)
target_compile_options(planck-blog_test PRIVATE -Wall -Wextra -Wpedantic)
target_include_directories(planck-blog_test PRIVATE
${INCLUDES}
${googletest_SOURCE_DIR}/googletest/include
${googletest_SOURCE_DIR}/googlemock/include
)
target_link_libraries(planck-blog_test PRIVATE
${LIBS}
GTest::gtest_main
GTest::gmock_main
)
enable_testing()
include(GoogleTest)
gtest_discover_tests(planck-blog_test
# Need this so that the unit tests can find the templates.
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})