-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
177 lines (152 loc) · 5.84 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
cmake_minimum_required(VERSION 3.15)
project(InVasionServers CXX)
#### adding subdirs
add_subdirectory(./include/)
add_subdirectory(./tests/)
add_subdirectory(./include/libs/bcrypt)
#### variables propagations
# GAME-MODELS-SRCS - propagated from ./include/game-models
# INTERACTORS-SRCS - propagated from ./include/interactors
# CONTROLLERS-SRCS - propagated from ./include/controllers
# GAME-MODELS-TESTS-SRCS - propagated from ./tests/game-models
# CONTROLLERS-TESTS-SRCS - propagated from ./tests/controllers
# GAME-SERVER-SRCS - propagated from ./include/server
# UTILS-SRCS - propagated from ./include/utils
# DATABASE-SRCS - propagated from ./include/database
# HTTP-SERVER-SRCS - propagated from ./include/http-server
# BCRYPT-SRCS - propagated from ./include/libs/bcrypt
#### setting names for executables
set(TESTS_TARGET tests)
set(SERVER_TARGET server)
#### setting global props
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
#### Protobuf
find_package(Protobuf REQUIRED)
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS
# request-models
./src/proto/request-models/move-request-model.proto
./src/proto/request-models/update-game-state-request-model.proto
./src/proto/request-models/rotate-weapon-request-model.proto
./src/proto/request-models/shoot-request-model.proto
./src/proto/request-models/respawn-player-request-model.proto
./src/proto/request-models/game-session-ended-request-model.proto
./src/proto/request-models/change-player-specialization-request-model.proto
./src/proto/request-models/apply-ability-request-model.proto
./src/proto/request-models/use-supply-request-model.proto
./src/proto/request-models/weapon-direction-request-model.proto
./src/proto/request-models/reload-weapon-request-model.proto
./src/proto/request-models/client-credentials-request-model.proto
# utils
./src/proto/utils/vector2d.proto
./src/proto/utils/player-specialization.proto
./src/proto/utils/player-team-id.proto
./src/proto/utils/supply-model.proto
./src/proto/utils/supply-type.proto
./src/proto/utils/player-health-model.proto
./src/proto/utils/player-data-model.proto
./src/proto/utils/game-match-result.proto
# response-models
./src/proto/response-models/player-position-response-model.proto
./src/proto/response-models/weapon-state-response-model.proto
./src/proto/response-models/bullet-position-response-model.proto
./src/proto/response-models/game-state-response-model.proto
./src/proto/response-models/damaged-player-response-model.proto
./src/proto/response-models/killed-player-response-model.proto
./src/proto/response-models/respawn-player-response-model.proto
./src/proto/response-models/game-session-stats-response-model.proto
./src/proto/response-models/player-game-session-stats-response-model.proto
./src/proto/response-models/game-over-response-model.proto
./src/proto/response-models/player-specialization-response-model.proto
./src/proto/response-models/supply-response-model.proto
./src/proto/response-models/use-supply-response-model.proto
./src/proto/response-models/handshake-response-model.proto
./src/proto/response-models/update-player-ammo-response-model.proto
./src/proto/response-models/update-player-hitpoints-response-model.proto
./src/proto/response-models/weapon-direction-response-model.proto
./src/proto/response-models/username-response-model.proto
./src/proto/response-models/client-connected-response-model.proto
./src/proto/response-models/client-disconnected-response-model.proto
)
message(NOTICE "Protoc compiler: " ${Protobuf_PROTOC_EXECUTABLE})
message(NOTICE "Bin dir: " ${CMAKE_CURRENT_BINARY_DIR})
message(NOTICE "Proto Source: " ${PROTO_SRCS})
message(NOTICE "Proto Headers: " ${PROTO_HDRS})
message(NOTICE "Proto Libraries: " ${Protobuf_LIBRARIES})
#### compile options for all targets
if (MSVC)
# warning level 4 and all warnings as errors
add_compile_options(
/experimental:external /external:I ${Protobuf_INCLUDE_DIR}/google/protobuf /external:W0)
# /W4 /WX)
else ()
# lots of warnings and all warnings as errors
# add_compile_options(-Wall -Wextra -Werror)
endif ()
#### configuring TESTS_TARGET:
add_executable(${TESTS_TARGET}
src/doctest_main.cpp
${GAME-MODELS-TESTS-SRCS}
${CONTROLLERS-TESTS-SRCS}
${GAME-MODELS-SRCS}
${INTERACTORS-SRCS}
${CONTROLLERS-SRCS}
${UTILS-SRCS}
${PROTO_SRCS}
${PROTO_HDRS}
)
target_include_directories(${TESTS_TARGET} PUBLIC
./doctest
./include
${Protobuf_INCLUDE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
if (WIN32 AND NOT MSVC AND NOT BORLAND)
target_link_libraries(${TESTS_TARGET} ws2_32 ${Protobuf_LIBRARIES})
else ()
find_package(Threads REQUIRED)
target_link_libraries(${TESTS_TARGET} PRIVATE Threads::Threads ${Protobuf_LIBRARIES})
endif ()
#### configuring SERVER_TARGET:
add_executable(${SERVER_TARGET}
src/main.cpp
${BCRYPT-SRCS}
# ./include/libs/bcrypt/src/bcrypt_impl.cpp
# ./include/libs/bcrypt/src/blowfish.cpp
${GAME-MODELS-SRCS}
${INTERACTORS-SRCS}
${CONTROLLERS-SRCS}
${GAME-SERVER-SRCS}
${UTILS-SRCS}
${DATABASE-SRCS}
${HTTP-SERVER-SRCS}
${PROTO_SRCS}
${PROTO_HDRS}
)
# including Protobuf dirs to server target
target_include_directories(${SERVER_TARGET} PUBLIC
./doctest
./include
${Protobuf_INCLUDE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
# including thread libs for Linux and Windows GCC Compiler
if (MSVC) # WIN32 AND NOT MSVC AND NOT BORLAND
target_compile_definitions(${SERVER_TARGET} PRIVATE -D_WIN32_WINNT=0x0A00)
find_package(unofficial-sqlite3 CONFIG REQUIRED)
target_link_libraries(${SERVER_TARGET} PRIVATE
# ws2_32
unofficial::sqlite3::sqlite3
${Protobuf_LIBRARIES}
)
else ()
find_package(Threads REQUIRED)
target_link_libraries(${SERVER_TARGET} PRIVATE
Threads::Threads
#==== for http-server ======
gcov
sqlite3
#==========
${Protobuf_LIBRARIES}
)
endif ()