-
Notifications
You must be signed in to change notification settings - Fork 17
/
CMakeLists.txt
312 lines (271 loc) · 14.6 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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
##################################################################################
# __ _
# / _| |__ __ _ ___ ___ _ ____ _____ _ __
# | |_| '_ \ / _` | ___ / __|/ _ \ '__\ \ / / _ \ '__|
# | _| | | | (_| ||___|\__ \ __/ | \ V / __/ |
# |_| |_| |_|\__, | |___/\___|_| \_/ \___|_|
# |_|
#
# Copyright (c) 2011-2024 FreeHackQuest <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
##################################################################################
# fhq-server CMake script
cmake_minimum_required(VERSION 3.0)
project(fhq-server)
include(${CMAKE_CURRENT_SOURCE_DIR}/src.wsjcpp/CMakeLists.txt)
#### BEGIN_WSJCPP_APPEND
#### END_WSJCPP_APPEND
set (CMAKE_AUTOMOC ON)
set (CMAKE_CXX_STANDARD 17)
set (EXECUTABLE_OUTPUT_PATH ${fhq-server_SOURCE_DIR})
set (QTCORE_LIBRARIES ${Qt5Core_LIBRARIES})
include_directories(${Qt5Core_INCLUDE_DIRS})
# Sources
# include header dirs
list (APPEND WSJCPP_INCLUDE_DIRS "src")
list (APPEND WSJCPP_INCLUDE_DIRS "src/argument_processors")
list (APPEND WSJCPP_INCLUDE_DIRS "src/core")
list (APPEND WSJCPP_INCLUDE_DIRS "src/core/3rdParty")
list (APPEND WSJCPP_INCLUDE_DIRS "src/third-party/quazip-0.7.3/quazip")
list (APPEND WSJCPP_INCLUDE_DIRS "src/utils")
list (APPEND WSJCPP_INCLUDE_DIRS "src/validators")
list (APPEND WSJCPP_INCLUDE_DIRS "src/employees")
list (APPEND WSJCPP_INCLUDE_DIRS "src/models")
list (APPEND WSJCPP_INCLUDE_DIRS "src/server")
list (APPEND WSJCPP_INCLUDE_DIRS "src/tasks")
list (APPEND WSJCPP_INCLUDE_DIRS "src/storages")
list (APPEND WSJCPP_INCLUDE_DIRS "src/storages/updates")
list (APPEND WSJCPP_INCLUDE_DIRS "src/cmd")
list (APPEND WSJCPP_INCLUDE_DIRS "src/web-server")
# argument_processor
list (APPEND WSJCPP_SOURCES "./src/argument_processors/argument_processor_main.cpp")
list (APPEND WSJCPP_SOURCES "./src/argument_processors/argument_processor_api.cpp")
list (APPEND WSJCPP_SOURCES "./src/argument_processors/argument_processor_config.cpp")
list (APPEND WSJCPP_SOURCES "./src/argument_processors/argument_processor_database.cpp")
# core
list (APPEND WSJCPP_SOURCES "src/core/cmd_handlers.h")
list (APPEND WSJCPP_SOURCES "src/core/cmd_handlers.cpp")
list (APPEND WSJCPP_SOURCES "src/core/export_libwsjcppcli_java_android.h")
list (APPEND WSJCPP_SOURCES "src/core/export_libwsjcppcli_java_android.cpp")
list (APPEND WSJCPP_SOURCES "src/core/export_libwsjcppcli_py.h")
list (APPEND WSJCPP_SOURCES "src/core/export_libwsjcppcli_py.cpp")
list (APPEND WSJCPP_SOURCES "src/core/jobs_pool.h")
list (APPEND WSJCPP_SOURCES "src/core/jobs_pool.cpp")
list (APPEND WSJCPP_SOURCES "src/core/websocketserver.h")
list (APPEND WSJCPP_SOURCES "src/core/websocketserver.cpp")
list (APPEND WSJCPP_SOURCES "src/core/employees.h")
list (APPEND WSJCPP_SOURCES "src/core/employees.cpp")
list (APPEND WSJCPP_SOURCES "src/core/wsjcpp_export_libcli_web_js.h")
list (APPEND WSJCPP_SOURCES "src/core/wsjcpp_export_libcli_web_js.cpp")
# quazip
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/crypt.h")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/ioapi.h")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/JlCompress.h")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/quaadler32.h")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/quachecksum32.h")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/quacrc32.h")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/quagzipfile.h")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/quaziodevice.h")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/quazipdir.h")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/quazipfile.h")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/quazipfileinfo.h")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/quazip_global.h")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/quazip.h")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/quazipnewinfo.h")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/unzip.h")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/zip.h")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/qioapi.cpp")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/JlCompress.cpp")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/quaadler32.cpp")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/quacrc32.cpp")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/quagzipfile.cpp")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/quaziodevice.cpp")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/quazip.cpp")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/quazipdir.cpp")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/quazipfile.cpp")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/quazipfileinfo.cpp")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/quazipnewinfo.cpp")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/unzip.c")
list (APPEND WSJCPP_SOURCES "src/third-party/quazip-0.7.3/quazip/zip.c")
# cmd
list (APPEND WSJCPP_SOURCES "src/cmd/cmd_handlers_classbook.cpp")
list (APPEND WSJCPP_SOURCES "src/cmd/cmd_handlers_communication.cpp")
list (APPEND WSJCPP_SOURCES "src/cmd/cmd_handlers_events.cpp")
list (APPEND WSJCPP_SOURCES "src/cmd/cmd_handlers_games.cpp")
list (APPEND WSJCPP_SOURCES "src/cmd/cmd_handlers_leaks.cpp")
list (APPEND WSJCPP_SOURCES "src/cmd/cmd_handlers_lxd.cpp")
list (APPEND WSJCPP_SOURCES "src/cmd/cmd_handlers_mails.cpp")
list (APPEND WSJCPP_SOURCES "src/cmd/cmd_handlers_quests_writeups.cpp")
list (APPEND WSJCPP_SOURCES "src/cmd/cmd_handlers_quests.cpp")
list (APPEND WSJCPP_SOURCES "src/cmd/cmd_handlers_server.cpp")
list (APPEND WSJCPP_SOURCES "src/cmd/cmd_handlers_support.cpp")
list (APPEND WSJCPP_SOURCES "src/cmd/cmd_handlers_useful_links.cpp")
list (APPEND WSJCPP_SOURCES "src/cmd/cmd_handlers_users.cpp")
# models
list (APPEND WSJCPP_SOURCES "src/models/model_game.cpp")
list (APPEND WSJCPP_SOURCES "src/models/model_notification.cpp")
list (APPEND WSJCPP_SOURCES "src/models/model_quest_file.cpp")
list (APPEND WSJCPP_SOURCES "src/models/model_database_connection.cpp")
list (APPEND WSJCPP_SOURCES "src/models/model_leak.cpp")
list (APPEND WSJCPP_SOURCES "src/models/model_lxd_orchestra.cpp")
# validators
list (APPEND WSJCPP_SOURCES "src/validators/validators.cpp")
list (APPEND WSJCPP_SOURCES "src/validators/validators.h")
# TODO include only if libmysqlclient exists
list (APPEND WSJCPP_INCLUDE_DIRS "src/storages/mysql")
list (APPEND WSJCPP_SOURCES "src/storages/mysql/mysql_storage.cpp")
list (APPEND WSJCPP_SOURCES "src/storages/mysql/mysql_storage.h")
# utils
list (APPEND WSJCPP_SOURCES "src/utils/utils_prepare_deb_package.h")
list (APPEND WSJCPP_SOURCES "src/utils/utils_prepare_deb_package.cpp")
list (APPEND WSJCPP_SOURCES "src/utils/utils_lxd.h")
list (APPEND WSJCPP_SOURCES "src/utils/utils_lxd.cpp")
# employees
list (APPEND WSJCPP_SOURCES "src/employees/employ_chats.cpp")
list (APPEND WSJCPP_SOURCES "src/employees/employ_images.cpp")
list (APPEND WSJCPP_SOURCES "src/employees/employ_games.cpp")
list (APPEND WSJCPP_SOURCES "src/employees/employ_files.cpp")
list (APPEND WSJCPP_SOURCES "src/employees/employ_notify.cpp")
list (APPEND WSJCPP_SOURCES "src/employees/employ_quests.cpp")
list (APPEND WSJCPP_SOURCES "src/employees/employ_server_info.cpp")
list (APPEND WSJCPP_SOURCES "src/employees/employ_scoreboard.cpp")
list (APPEND WSJCPP_SOURCES "src/employees/employ_database.cpp")
list (APPEND WSJCPP_SOURCES "src/employees/employ_orchestra.cpp")
list (APPEND WSJCPP_SOURCES "src/employees/employ_leaks.cpp")
list (APPEND WSJCPP_SOURCES "src/employees/employ_mails.cpp")
list (APPEND WSJCPP_SOURCES "src/employees/employ_users.cpp")
# tasks
list (APPEND WSJCPP_SOURCES "src/tasks/runtasks.h")
list (APPEND WSJCPP_SOURCES "src/tasks/runtasks.cpp")
list (APPEND WSJCPP_SOURCES "src/tasks/mail_send_task.h")
list (APPEND WSJCPP_SOURCES "src/tasks/mail_send_task.cpp")
list (APPEND WSJCPP_SOURCES "src/tasks/notify_to_all_task.h")
list (APPEND WSJCPP_SOURCES "src/tasks/notify_to_all_task.cpp")
list (APPEND WSJCPP_SOURCES "src/tasks/add_public_events_task.h")
list (APPEND WSJCPP_SOURCES "src/tasks/add_public_events_task.cpp")
list (APPEND WSJCPP_SOURCES "src/tasks/update_max_score_game_task.h")
list (APPEND WSJCPP_SOURCES "src/tasks/update_max_score_game_task.cpp")
list (APPEND WSJCPP_SOURCES "src/tasks/update_quest_solved_task.h")
list (APPEND WSJCPP_SOURCES "src/tasks/update_quest_solved_task.cpp")
list (APPEND WSJCPP_SOURCES "src/tasks/update_user_location_task.h")
list (APPEND WSJCPP_SOURCES "src/tasks/update_user_location_task.cpp")
list (APPEND WSJCPP_SOURCES "src/tasks/update_user_rating_task.h")
list (APPEND WSJCPP_SOURCES "src/tasks/update_user_rating_task.cpp")
list (APPEND WSJCPP_SOURCES "src/tasks/lxd_async_operation_task.h")
list (APPEND WSJCPP_SOURCES "src/tasks/lxd_async_operation_task.cpp")
# updates
list (APPEND WSJCPP_SOURCES "src/storages/updates/updates_init_database.cpp")
list (APPEND WSJCPP_SOURCES "src/storages/updates/update0100.cpp")
list (APPEND WSJCPP_SOURCES "src/storages/updates/update_u0100_mhd92m15nb.cpp")
list (APPEND WSJCPP_SOURCES "src/storages/updates/update_mhd92m15nb_snwxenqco0.cpp")
list (APPEND WSJCPP_SOURCES "src/storages/updates/update_snwxenqco0_csww6lwcrp.cpp")
list (APPEND WSJCPP_SOURCES "src/storages/updates/update_csww6lwcrp_722kt134lq.cpp")
list (APPEND WSJCPP_SOURCES "src/storages/updates/update_722kt134lq_6c8d4zm6u2.cpp")
list (APPEND WSJCPP_SOURCES "src/storages/updates/update_6c8d4zm6u2_pmlyt8k7nm.cpp")
list (APPEND WSJCPP_SOURCES "src/storages/updates/update_pmlyt8k7nm_215438peu8.cpp")
list (APPEND WSJCPP_SOURCES "src/storages/updates/update_215438peu8_9gwc2tm5ah.cpp")
list (APPEND WSJCPP_SOURCES "src/storages/updates/update_9gwc2tm5ah_on73sheet9.cpp")
list (APPEND WSJCPP_SOURCES "src/storages/updates/update_on73sheet9_ili7looowo.cpp")
list (APPEND WSJCPP_SOURCES "src/storages/updates/update0101.cpp")
# web-server
list (APPEND WSJCPP_SOURCES "src/web-server/http_handler_web_user_folder.cpp")
list (APPEND WSJCPP_SOURCES "src/web-server/http_handler_web_user_folder.h")
list (APPEND WSJCPP_SOURCES "src/web-server/http_handler_web_public_folder.cpp")
list (APPEND WSJCPP_SOURCES "src/web-server/http_handler_web_public_folder.h")
list (APPEND WSJCPP_SOURCES "src/web-server/http_handler_web_admin_folder.cpp")
list (APPEND WSJCPP_SOURCES "src/web-server/http_handler_web_admin_folder.h")
# main
list (APPEND WSJCPP_SOURCES "src/main.cpp")
############################
#####
#foreach (_headerFile ${WSJCPP_HEADERS})
# get_filename_component(_dir ${_headerFile} PATH)
# list (APPEND WSJCPP_INCLUDE_DIRS ${_dir})
#endforeach()
#list(REMOVE_DUPLICATES WSJCPP_INCLUDE_DIRS)
#####
############################
############################
##### ZLIB
find_package( ZLIB REQUIRED )
if ( ZLIB_FOUND )
list (APPEND WSJCPP_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS})
include_directories( ${ZLIB_INCLUDE_DIRS} )
list (APPEND WSJCPP_LIBRARIES ${ZLIB_LIBRARIES})
endif( ZLIB_FOUND )
#####
############################
############################
##### mysql
# Find and make sure the system have the header file
find_path(MYSQL_HEADER mysql/mysql.h)
if(MYSQL_HEADER STREQUAL "MYSQL_HEADER-NOTFOUND")
message(FATAL_ERROR "Could not find the mysql/mysql.h header file: (ubuntu: apt install libmysqlclient-dev) or (debian: apt install default-libmariadbclient-dev and link: ln -s /usr/lib/x86_64-linux-gnu/pkgconfig/mariadb.pc /usr/lib/x86_64-linux-gnu/pkgconfig/mysqlclient.pc)")
endif()
include(FindPkgConfig)
pkg_check_modules(LIBMYSQLCLIENT REQUIRED mysqlclient)
foreach(FLAG ${LIBMYSQLCLIENT_CFLAGS_OTHER})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAG}")
endforeach()
list (APPEND WSJCPP_INCLUDE_DIRS ${LIBMYSQLCLIENT_LIBRARY_DIRS})
list (APPEND WSJCPP_LIBRARIES ${LIBMYSQLCLIENT_LIBRARIES})
#####
############################
# libhv
set(WITH_OPENSSL OFF CACHE BOOL "")
set(WITH_CURL OFF CACHE BOOL "")
# set(WITH_MQTT OFF CACHE BOOL "")
# set(WITH_EVPP OFF CACHE BOOL "")
set(BUILD_EXAMPLES OFF CACHE BOOL "")
# set(WITH_HTTP_CLIENT OFF CACHE BOOL "")
set(BUILD_SHARED OFF CACHE BOOL "")
add_subdirectory(src/third-party/libhv)
list (APPEND WSJCPP_LIBRARIES hv_static)
list (APPEND WSJCPP_INCLUDE_DIRS "${PROJECT_BINARY_DIR}/src/third-party/libhv/include/hv")
add_subdirectory(src/third-party/sqlite3)
# https://www.sqlite.org/threadsafe.html
# target_compile_definitions(sqlite3-static
# PRIVATE
# SQLITE_THREADSAFE=0
# )
list (APPEND WSJCPP_LIBRARIES sqlite3-static)
message(STATUS "Sqlite Includes: ${PROJECT_SOURCE_DIR}/src/third-party/sqlite3/src")
list (APPEND WSJCPP_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src/third-party/sqlite3/src")
include_directories(${WSJCPP_INCLUDE_DIRS})
find_package (Qt5Core)
find_package (Qt5Sql)
find_package (Qt5Network)
find_package (Qt5WebSockets)
add_executable (fhq-server ${WSJCPP_SOURCES})
qt5_use_modules(fhq-server Core Network Sql WebSockets)
target_link_libraries(fhq-server ${WSJCPP_LIBRARIES} )
# target_link_libraries(fhq-server Qt5::Core)
install(
TARGETS
fhq-server
RUNTIME DESTINATION
${CMAKE_INSTALL_PREFIX}/bin
)
# install(FILES install_files/fhq-server.conf.sample DESTINATION ${CMAKE_INSTALL_PREFIX}/../etc/fhq-server COMPONENT config)
# install(FILES install_files/fhq-server.service DESTINATION ${CMAKE_INSTALL_PREFIX}/../etc/systemd/system COMPONENT config)
# install(FILES install_files/fhq-server.postinst DESTINATION ${CMAKE_INSTALL_PREFIX}/../var/lib/dpkg/info COMPONENT config)
# install(DIRECTORY DESTINATION ${CMAKE_INSTALL_PREFIX}/share/fhq-server)
# install(DIRECTORY DESTINATION ${CMAKE_INSTALL_PREFIX}/log/fhq-server)