-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
242 lines (215 loc) · 10.5 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
cmake_minimum_required(VERSION 3.14) # CMake version check
##
## PROJECT
## name and version
##
project(Sane++ VERSION "0.3.0") # Create project
# Project config files directory.
include_directories(config)
# Get git version info.
include(config/git_version.cmake)
# Generate config header file.
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config/config.hpp.in"
"${CMAKE_CURRENT_SOURCE_DIR}/config/config.hpp")
##
## COMPILER
##
set(CMAKE_CXX_STANDARD 14) # Enable c++14 standard
##
## OPTIONS
##
option(SanePP_BuildTests "Build the unit tests when BUILD_TESTING is enabled." ON)
# DEBUG Flags, TODO: Figure out some RELEASE flags.
set(CMAKE_CXX_FLAGS "-std=c++17 -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic")
include_directories(libsane++/src)
include_directories(libsane++/include)
include_directories(cli)
include_directories(gui)
include_directories(third_party)
include_directories(tests)
## Shared Libs
# Shared resources // FIXME: Import the local lib libsane++ the proper way.
#find_library(libsane++)
#add_library(libsane++ PATHS libsane++)
# ICU/Unicode
# ICU Components Reference:
# https://cmake.org/cmake/help/latest/module/FindICU.html
# ICU components = data, i18n, io, le, lx, test, tu and uc.
#find_package(ICU COMPONENTS uc REQUIRED)
# Command find_package in cmake doesn’t support SQLite.
# So, to link SQLite you have to go about it in a roundabout way...
set (LIB_DIR_LOCATION ${NAME}/lib)
find_library(sqlite3 NAMES sqlite3 PATHS ${LIB_DIR_LOCATION})
set(INCLUDE_DIRS ${NAME}/include)
# CLI
add_executable(sane++_cli config/config.hpp cli/src/main.cpp
cli/src/cli.cpp
cli/src/cli.hpp
libsane++/src/api_handler/api_handler.cpp
libsane++/include/api_handler/api_handler.hpp
libsane++/src/entities/youtube_channel.cpp
libsane++/include/entities/youtube_channel.hpp
libsane++/src/db_handler/db_handler.cpp
libsane++/include/db_handler/db_handler.hpp
libsane++/src/db_handler/db_youtube_channels.cpp
libsane++/include/db_handler/db_youtube_channels.hpp
third_party/nlohmann/json.hpp
libsane++/src/api_handler/entity_response.cpp
libsane++/src/api_handler/json_response.cpp
cli/src/entity_commands.cpp
cli/src/json_commands.cpp
cli/src/print_functions.cpp
libsane++/src/youtube/subfeed.cpp
libsane++/include/youtube/subfeed.hpp
libsane++/src/entities/youtube_video.cpp
libsane++/include/entities/youtube_video.hpp
libsane++/include/entities/common.hpp
libsane++/include/types.hpp
libsane++/src/entities/common.cpp
libsane++/src/types.cpp libsane++/src/lexical_analysis.cpp libsane++/include/lexical_analysis.hpp libsane++/src/youtube/toolkit.cpp libsane++/include/youtube/toolkit.hpp libsane++/src/config_handler/config_handler.cpp libsane++/include/config_handler/config_handler.hpp third_party/yhirose/httplib.h libsane++/src/youtube/list_videos_thread.cpp libsane++/include/youtube/list_videos_thread.hpp)
# API Handler
target_link_libraries (sane++_cli -lcurl)
# Database
target_link_libraries(sane++_cli -lpthread)
target_link_libraries(sane++_cli -ldl)
target_link_libraries(sane++_cli sqlite3)
#target_link_libraries(sane++_cli ICU::uc)
target_include_directories(sane++_cli PRIVATE ${INCLUDE_DIRS})
# GUI
add_executable(sane++_gui config/config.hpp gui/src/main.cpp
libsane++/src/entities/youtube_channel.cpp
libsane++/include/entities/youtube_channel.hpp
libsane++/src/db_handler/db_handler.cpp
libsane++/include/db_handler/db_handler.hpp
libsane++/src/db_handler/db_youtube_channels.cpp
libsane++/include/db_handler/db_youtube_channels.hpp
libsane++/src/api_handler/api_handler.cpp
libsane++/include/api_handler/api_handler.hpp
libsane++/src/api_handler/entity_response.cpp
libsane++/src/api_handler/json_response.cpp
libsane++/src/youtube/subfeed.cpp
libsane++/include/youtube/subfeed.hpp
libsane++/src/entities/youtube_video.cpp
libsane++/include/entities/youtube_video.hpp
libsane++/include/entities/common.hpp
libsane++/include/types.hpp
libsane++/src/entities/common.cpp
libsane++/src/types.cpp libsane++/src/lexical_analysis.cpp libsane++/include/lexical_analysis.hpp libsane++/src/youtube/toolkit.cpp libsane++/include/youtube/toolkit.hpp libsane++/src/config_handler/config_handler.cpp libsane++/include/config_handler/config_handler.hpp third_party/yhirose/httplib.h libsane++/src/youtube/list_videos_thread.cpp libsane++/include/youtube/list_videos_thread.hpp)
# API Handler
target_link_libraries (sane++_gui -lcurl)
# Database
target_link_libraries(sane++_gui -lpthread)
target_link_libraries(sane++_gui -ldl)
#target_link_libraries (SaneGUI ${SQLITE3_LIBRARIES})
target_link_libraries(sane++_gui sqlite3)
#target_link_libraries(sane++_gui ICU::uc)
target_include_directories(sane++_gui PRIVATE ${INCLUDE_DIRS})
##
## TESTS
## create and configure the unit test target
##
#include(CTest) # adds option BUILD_TESTING (default ON)
#
#if(BUILD_TESTING AND SanePP_BuildTests)
# enable_testing()
#
# # Add the entire test/ directory
# add_subdirectory(test)
#
# # Link local libraries
# SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
#endif()
enable_testing()
find_package(Catch2 REQUIRED)
if(DEFINED ENV{THIS_IS_TRAVIS})
message("Building tests for Travis CI env...")
add_executable(travis_test_all config/config.hpp tests/test_all.cpp
cli/src/cli.cpp
cli/src/cli.hpp
cli/test/unit-test_cli.cpp
libsane++/src/api_handler/api_handler.cpp
libsane++/include/api_handler/api_handler.hpp
libsane++/src/entities/youtube_channel.cpp
libsane++/include/entities/youtube_channel.hpp
libsane++/src/db_handler/db_handler.cpp
libsane++/include/db_handler/db_handler.hpp
libsane++/test/db_handler/unit-test_exec_sql_statement_default_callback.cpp
libsane++/src/db_handler/db_youtube_channels.cpp
libsane++/include/db_handler/db_youtube_channels.hpp
third_party/nlohmann/json.hpp
libsane++/test/db_handler/unit-test_001_create_table_youtube_channels.cpp
libsane++/test/entities/unit-test_001_create_youtube_channel_from_map.cpp
libsane++/test/entities/unit-test_002_create_youtube_channel_from_json.cpp
libsane++/src/api_handler/entity_response.cpp
libsane++/src/api_handler/json_response.cpp
cli/src/entity_commands.cpp
cli/src/json_commands.cpp
cli/src/print_functions.cpp
libsane++/src/youtube/subfeed.cpp
libsane++/include/youtube/subfeed.hpp
libsane++/src/entities/youtube_video.cpp
libsane++/include/entities/youtube_video.hpp
libsane++/include/entities/common.hpp
libsane++/include/types.hpp
libsane++/src/entities/common.cpp
libsane++/src/types.cpp libsane++/test/unit-test_001_datetime_t.cpp libsane++/src/lexical_analysis.cpp libsane++/include/lexical_analysis.hpp libsane++/src/youtube/toolkit.cpp libsane++/include/youtube/toolkit.hpp libsane++/src/config_handler/config_handler.cpp libsane++/include/config_handler/config_handler.hpp third_party/yhirose/httplib.h libsane++/src/youtube/list_videos_thread.cpp libsane++/include/youtube/list_videos_thread.hpp)
# API Handler
target_link_libraries(travis_test_all -lcurl)
# Testing suite.
target_link_libraries(travis_test_all Catch2::Catch2)
# Database.
target_link_libraries(travis_test_all -lpthread)
target_link_libraries(travis_test_all -ldl)
target_link_libraries(travis_test_all sqlite3)
# target_link_libraries(travis_test_all ICU::uc)
target_include_directories(travis_test_all PRIVATE ${INCLUDE_DIRS})
include(CTest)
include(Catch)
catch_discover_tests(travis_test_all)
else()
message("Building tests for normal env...")
add_executable(test_all config/config.hpp tests/test_all.cpp
cli/src/cli.cpp
cli/src/cli.hpp
cli/test/unit-test_cli.cpp
libsane++/src/api_handler/api_handler.cpp
libsane++/include/api_handler/api_handler.hpp
libsane++/src/entities/youtube_channel.cpp
libsane++/include/entities/youtube_channel.hpp
libsane++/src/db_handler/db_handler.cpp
libsane++/include/db_handler/db_handler.hpp
libsane++/test/db_handler/unit-test_exec_sql_statement_default_callback.cpp
libsane++/src/db_handler/db_youtube_channels.cpp
libsane++/include/db_handler/db_youtube_channels.hpp
third_party/nlohmann/json.hpp
libsane++/test/db_handler/unit-test_001_create_table_youtube_channels.cpp
libsane++/test/db_handler/unit-test_002_add_channels.cpp
libsane++/test/entities/unit-test_001_create_youtube_channel_from_map.cpp
libsane++/test/entities/unit-test_002_create_youtube_channel_from_json.cpp
libsane++/src/api_handler/entity_response.cpp
libsane++/src/api_handler/json_response.cpp
cli/src/entity_commands.cpp
cli/src/json_commands.cpp
cli/src/print_functions.cpp
libsane++/src/youtube/subfeed.cpp
libsane++/include/youtube/subfeed.hpp
libsane++/src/entities/youtube_video.cpp
libsane++/include/entities/youtube_video.hpp
libsane++/include/entities/common.hpp
libsane++/include/types.hpp
libsane++/src/entities/common.cpp
libsane++/src/types.cpp libsane++/test/unit-test_001_datetime_t.cpp libsane++/src/lexical_analysis.cpp libsane++/include/lexical_analysis.hpp libsane++/src/youtube/toolkit.cpp libsane++/include/youtube/toolkit.hpp libsane++/src/config_handler/config_handler.cpp libsane++/include/config_handler/config_handler.hpp third_party/yhirose/httplib.h libsane++/src/youtube/list_videos_thread.cpp libsane++/include/youtube/list_videos_thread.hpp)
# API Handler
target_link_libraries(test_all -lcurl)
# Testing suite.
target_link_libraries(test_all Catch2::Catch2)
# Database.
target_link_libraries(test_all -lpthread)
target_link_libraries(test_all -ldl)
target_link_libraries(test_all sqlite3)
# target_link_libraries(test_all ICU::uc)
target_include_directories(test_all PRIVATE ${INCLUDE_DIRS})
include(CTest)
include(Catch)
catch_discover_tests(test_all)
endif()