-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
382 lines (302 loc) · 10.1 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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
cmake_minimum_required(VERSION 3.25)
project(creature-server
VERSION "2.2.13"
DESCRIPTION "Server for April's Creatures"
HOMEPAGE_URL https://github.com/opsnlops/creature-server
LANGUAGES C CXX)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 20)
# Overshadowed declarations keep biting me in the butt 😅
add_compile_options(-Wshadow)
add_compile_options(-Wall)
add_compile_options(-Wextra)
add_compile_options(-Wpedantic)
set(PACKAGE_AUTHOR "April White")
find_package(PkgConfig REQUIRED)
set(CMAKE_POLICY_DEFAULT_CMP0042 NEW)
# Make our version available to the project
configure_file(src/server/Version.h.in Version.h)
# Log loudly
include(FetchContent)
set(FETCHCONTENT_QUIET OFF)
# This project uses threads
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
# Why are UUIDs so hard in 2024
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
pkg_search_module(UUID REQUIRED uuid)
endif()
# fmt
message(STATUS "fmt")
FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt
GIT_TAG 9.1.0
)
FetchContent_MakeAvailable(fmt)
set(FMT_HEADER_ONLY ON)
set(FMT_LOCALE ON)
# spdlog
FetchContent_Declare(
spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog
GIT_TAG v1.11.0
)
FetchContent_MakeAvailable(spdlog)
# argparse
FetchContent_Declare(
argparse
GIT_REPOSITORY https://github.com/p-ranav/argparse.git
)
FetchContent_MakeAvailable(argparse)
# json
FetchContent_Declare(
json
URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz)
FetchContent_MakeAvailable(json)
# Google Test
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip
)
FetchContent_MakeAvailable(googletest)
# Use the oatpp that we've already made
find_package(oatpp REQUIRED PATHS ${CMAKE_SOURCE_DIR}/externals/install/lib/cmake/oatpp-1.3.0)
find_package(oatpp-swagger REQUIRED PATHS ${CMAKE_SOURCE_DIR}/externals/install/lib/cmake/oatpp-swagger-1.3.0)
find_package(oatpp-websocket REQUIRED PATHS ${CMAKE_SOURCE_DIR}/externals/install/lib/cmake/oatpp-websocket-1.3.0)
add_definitions(
## define path to swagger-ui static resources folder
-DOATPP_SWAGGER_RES_PATH="${oatpp-swagger_INCLUDE_DIRS}/../bin/oatpp-swagger/res"
)
# ...and our own libraries
add_subdirectory(lib/e131_service)
add_subdirectory(lib/CreatureVoicesLib)
# Set up a base64 encoder/decoder
set(LIBBASE64_DIR "${CMAKE_SOURCE_DIR}/lib/base64")
# Set up a concurrent queue
set(MOODYCAMEL_DIR "${CMAKE_SOURCE_DIR}/lib/concurrentqueue")
#
# If we're on macOS, use the local copy of the Swagger UI. On Linux, use the one from the
# package that we installed.
#
if(APPLE)
add_definitions(-DSWAGGER_UI_PATH="${CMAKE_SOURCE_DIR}/externals/build/oatpp-swagger-prefix/src/oatpp-swagger/res/")
else()
add_definitions(-DSWAGGER_UI_PATH="/usr/share/creature-server/swagger-ui/")
endif()
# MongoDB (built by us on Linux, but the macOS/brew version is fine)
find_package(mongocxx REQUIRED)
find_package(bsoncxx REQUIRED)
# SDL
find_package(SDL2 REQUIRED)
find_package(SDL2_mixer REQUIRED)
# Leave a message
message(STATUS "Using SDL2 includes ${SDL2_INCLUDE_DIRS}")
# Our source files
file(GLOB serverFiles
src/util/*
src/exception/*
src/server/*
src/server/animation/*
src/server/config/*
src/server/creature/*
src/server/eventloop/*
src/server/eventloop/events/*
src/server/gpio/*
src/server/logging/*
src/server/metrics/*
src/server/playlist/*
src/server/watchdog/*
src/model/*
)
file(GLOB clientFiles
src/client/*
src/exception/*
src/util/*
)
file(GLOB logReaderFiles
src/client/*.h
src/exception/*
src/log-monitor/*
)
# Set up our includes
include_directories(
src/
util/
${UUID_INCLUDE_DIRS}
${argparse_SOURCE_DIR}/include
${SDL2_INCLUDE_DIRS}
${SDL2_MIXER_INCLUDE_DIRS}
${MOODYCAMEL_DIR}
${LIBBASE64_DIR}/include
${oatpp_INCLUDE_DIRS}
PRIVATE ${CMAKE_BINARY_DIR}
)
add_executable(creature-server
${serverFiles}
src/server/watchdog/Watchdog.cpp
src/server/watchdog/Watchdog.h
src/model/LogLevel.h
src/model/LogItem.h
src/model/AnimationMetadata.cpp
src/model/AnimationMetadata.h
src/model/Animation.cpp
src/model/Animation.h
src/model/CacheInvalidation.h
src/model/CacheInvalidation.cpp
src/model/Creature.h
src/model/Creature.cpp
src/model/Input.h
src/model/Input.cpp
src/model/LogLevel.h
src/model/LogItem.h
src/model/LogItem.cpp
src/model/Notice.h
src/model/Notice.cpp
src/model/Playlist.h
src/model/Playlist.cpp
src/model/PlaylistItem.h
src/model/PlaylistItem.cpp
src/model/PlaylistStatus.h
src/model/PlaylistStatus.cpp
src/model/StreamFrame.cpp
src/model/StreamFrame.h
src/model/Sound.h
src/model/Sound.cpp
src/model/SortBy.h
src/model/Track.cpp
src/model/Track.h
src/model/VirtualStatusLights.cpp
src/model/VirtualStatusLights.h
src/util/loggingUtils.cpp
src/util/loggingUtils.h
src/util/Result.cpp
src/util/Result.h
src/util/websocketUtils.h
src/util/websocketUtils.cpp
src/server/ws/AppComponent.h
src/server/ws/App.h
src/server/ws/App.cpp
src/server/ws/dto/ListDto.h
src/server/ws/dto/PlayAnimationRequestDto.h
src/server/ws/dto/PlaySoundRequestDTO.h
src/server/ws/dto/SimpleResponseDto.h
src/server/ws/dto/StatusDto.h
src/server/ws/ErrorHandler.cpp
src/server/ws/ErrorHandler.h
src/server/ws/controller/CreatureController.h
src/server/ws/controller/DebugController.h
src/server/ws/controller/MetricsController.h
src/server/ws/controller/SoundController.h
src/server/ws/controller/StaticController.h
src/server/ws/controller/WebSocketController.h
src/server/ws/dto/websocket/CacheInvalidationMessage.h
src/server/ws/dto/websocket/LogMessage.h
src/server/ws/dto/websocket/MessageTypes.h
src/server/ws/dto/websocket/MessageTypes.cpp
src/server/ws/dto/websocket/NoticeMessage.h
src/server/ws/dto/websocket/ServerCountersMessage.h
src/server/ws/dto/websocket/StreamFrameMessage.h
src/server/ws/dto/websocket/VirtualStatusLightsMessage.h
src/server/ws/dto/websocket/WebSocketMessageDto.h
src/server/ws/messaging/BasicCommandDto.h
src/server/ws/messaging/IMessageHandler.h
src/server/ws/messaging/NoticeMessageHandler.cpp
src/server/ws/messaging/NoticeMessageHandler.h
src/server/ws/messaging/MessageProcessor.h
src/server/ws/messaging/MessageProcessor.cpp
src/server/ws/messaging/StreamFrameHandler.h
src/server/ws/messaging/StreamFrameHandler.cpp
src/server/ws/service/AnimationService.h
src/server/ws/service/AnimationService.cpp
src/server/ws/service/CreatureService.h
src/server/ws/service/CreatureService.cpp
src/server/ws/service/MetricsService.h
src/server/ws/service/MetricsService.cpp
src/server/ws/service/PlaylistService.h
src/server/ws/service/PlaylistService.cpp
src/server/ws/service/SoundService.h
src/server/ws/service/SoundService.cpp
src/server/ws/service/VoiceService.h
src/server/ws/service/VoiceService.cpp
src/server/ws/websocket/ClientCafe.h
src/server/ws/websocket/ClientConnection.h
src/server/ws/websocket/ClientCafe.cpp
src/server/ws/websocket/ClientConnection.cpp
src/server/ws/messaging/NoticeMessageCommandDTO.h
src/server/ws/messaging/SensorReportHandler.h
src/server/ws/messaging/SensorReportHandler.cpp
)
target_compile_definitions(creature-server PRIVATE OATPP_THREAD_DISTRIBUTED)
target_link_libraries(creature-server
PRIVATE ${UUID_LIBRARIES}
spdlog::spdlog $<$<BOOL:${MINGW}>:ws2_32>
fmt::fmt
SDL2::SDL2
SDL2_mixer::SDL2_mixer
oatpp::oatpp
oatpp::oatpp-swagger
oatpp::oatpp-websocket
nlohmann_json::nlohmann_json
PRIVATE mongo::mongocxx_shared
PRIVATE mongo::bsoncxx_shared
argparse
e131_service
CreatureVoicesLib
)
install(TARGETS creature-server
COMPONENT creature-server
RUNTIME DESTINATION "/bin"
LIBRARY DESTINATION "/lib"
DESTINATION "/bin"
)
# Include the MongoDB C++ driver
install(DIRECTORY /usr/local/lib
DESTINATION /usr
COMPONENT creature-server
PATTERN "python" EXCLUDE
)
#
# Set up testing
#
enable_testing()
add_executable(creature-server-test
tests/model/Creature_test.cpp
tests/model/LogItem_test.cpp
tests/model/Animation_test.cpp
tests/model/AnimationMetadata_test.cpp
src/model/SortBy.h
src/model/Track.cpp
)
target_link_libraries(creature-server-test
PRIVATE ${UUID_LIBRARIES}
spdlog::spdlog $<$<BOOL:${MINGW}>:ws2_32>
fmt::fmt
SDL2::SDL2
SDL2_mixer::SDL2_mixer
oatpp::oatpp
oatpp::oatpp-swagger
oatpp::oatpp-websocket
nlohmann_json::nlohmann_json
PRIVATE mongo::mongocxx_shared
PRIVATE mongo::bsoncxx_shared
argparse
e131_service
CreatureVoicesLib
gtest_main
gmock_main
)
# This is to include Google Test and Google Mock headers
target_include_directories(creature-server-test PRIVATE
${googletest_SOURCE_DIR}/include
${googlemock_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/tests/
)
# Tell CMake where our tests are
set_property(TARGET creature-server-test PROPERTY FOLDER "tests")
# Register the test with CTest
include(GoogleTest)
gtest_discover_tests(creature-server-test)
# where to find our CMake modules
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(Package)