-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
236 lines (200 loc) · 8.58 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
cmake_minimum_required(VERSION 3.17)
project(R-Type)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
if (MSVC)
set (CMAKE_GENERATOR "Visual Studio 17" CACHE INTERNAL "" FORCE)
add_compile_definitions(WIN32_LEAN_AND_MEAN)
add_compile_definitions(_WIN32_WINNT=0x0601)
else()
set (CMAKE_GENERATOR "Unix Makefiles" CACHE INTERNAL "" FORCE)
add_compile_options(-g3 -pthread )
endif()
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
file(DOWNLOAD "https://raw.githubusercontent.com/vector-of-bool/cmrc/master/CMakeRC.cmake"
"${CMAKE_BINARY_DIR}/CMakeRC.cmake")
include("${CMAKE_BINARY_DIR}/CMakeRC.cmake")
message("=== Conan Libraries: ===")
message(${CONAN_LIBS})
message("========================")
function(build_server)
add_executable(Server
"${CMAKE_CURRENT_SOURCE_DIR}/src/server/main.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/server/Game.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/server/Systems/Factory.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/server/Systems/ArmamentSystem.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/server/Protocols/TcpServer.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/server/Protocols/LobbyProtocol.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/server/Protocols/Connections.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/server/Protocols/GameProtocol.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/server/Systems/VelocitySystem.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/server/Server.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/shared/ECS/CompPool.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/shared/ECS/Components.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/shared/ECS/ECSManager.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/shared/ECS/Serialization.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/shared/MessageQueue/MessageQueue.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/shared/Networking/UdpCommunication.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/shared/Systems/HitboxSystem.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/shared/Systems/JanitorSystem.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/shared/Utilities/UUID.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/shared/Utilities/Timer.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/shared/Utilities/Utilities.cpp"
)
target_compile_definitions(Server PUBLIC SERVER=1)
cmrc_add_resource_library(
server-resources
ALIAS server::rc
NAMESPACE server
src/server/levels/level1
src/server/levels/level2
src/server/levels/level3
src/server/levels/level4
src/server/levels/level5
src/server/levels/level6
src/server/levels/level7
src/server/levels/level8
)
target_link_libraries(Server server::rc)
target_link_libraries(Server ${CONAN_LIBS})
endfunction()
function(build_client)
add_executable(Client
"${CMAKE_CURRENT_SOURCE_DIR}/src/client/main.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/client/Client.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/client/ClientGame/ClientGame.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/client/GUI/Components/TextBox.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/client/GUI/Components/Button.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/client/GUI/Menus/Menu.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/client/GUI/Menus/ConnectionMenu.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/client/GUI/Menus/LobbyMenu.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/client/GUI/Menus/LobbySelectionMenu.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/client/Protocols/TcpClient.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/client/Protocols/ClientLobbyProtocol.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/client/Protocols/TcpClient.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/client/Systems/SpriteSystem.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/client/Systems/HealthSystem.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/client/Systems/MusicSystem.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/client/Systems/PlayerMovementSystem.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/shared/ECS/Serialization.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/shared/ECS/CompPool.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/shared/ECS/ECSManager.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/shared/ECS/Components.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/shared/Networking/UdpCommunication.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/shared/MessageQueue/MessageQueue.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/shared/Utilities/UUID.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/shared/Utilities/Utilities.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/shared/Utilities/Timer.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/client/Protocols/ClientGameProtocol.cpp"
)
target_compile_definitions(Client PUBLIC CLIENT=1)
cmrc_add_resource_library(
client-resources
ALIAS client::rc
NAMESPACE client
resources/r-typesheet1.png
resources/r-typesheet2.png
resources/r-typesheet3.png
resources/r-typesheet5.png
resources/r-typesheet7.png
resources/r-typesheet8.png
resources/r-typesheet9.png
resources/r-typesheet10.png
resources/r-typesheet11.png
resources/r-typesheet12.png
resources/r-typesheet13.png
resources/r-typesheet14.png
resources/r-typesheet16.png
resources/r-typesheet17.png
resources/r-typesheet18.png
resources/r-typesheet19.png
resources/r-typesheet20.png
resources/r-typesheet21.png
resources/r-typesheet22.png
resources/r-typesheet23.png
resources/r-typesheet24.png
resources/r-typesheet25.png
resources/r-typesheet26.png
resources/r-typesheet27.png
resources/r-typesheet28.png
resources/r-typesheet29.png
resources/r-typesheet30.png
resources/r-typesheet30a.png
resources/r-typesheet31.png
resources/r-typesheet32.png
resources/r-typesheet33.png
resources/r-typesheet34.png
resources/r-typesheet35.png
resources/r-typesheet36.png
resources/r-typesheet37.png
resources/r-typesheet38.png
resources/r-typesheet39.png
resources/r-typesheet40.png
resources/r-typesheet41.png
resources/r-typesheet42.png
resources/r-typesheet43.png
resources/r-typesheet44.png
resources/lost.png
resources/background.png
resources/citySunnset.png
resources/menu-background.png
resources/song0.mp3
resources/song1.mp3
resources/song2.mp3
resources/gunShot1.wav
resources/gunShot2.wav
resources/gunShot3.wav
)
target_link_libraries(Client client::rc)
target_link_libraries(Client ${CONAN_LIBS})
endfunction()
function(build_createFile)
add_executable(CreateFile
"${CMAKE_CURRENT_SOURCE_DIR}/src/createLevelFile/main.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/createLevelFile/Level.cpp"
)
target_compile_definitions(CreateFile PUBLIC CREATE_FILE=1)
target_link_libraries(CreateFile ${CONAN_LIBS})
endfunction()
function(build_tests)
include(FetchContent)
FetchContent_Declare(googletest URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
enable_testing()
set(SOURCE_CODE
"${CMAKE_CURRENT_SOURCE_DIR}/src/shared/ECS/CompPool.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/shared/ECS/ECSManager.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/shared/ECS/Components.cpp"
)
set(TEST_CODE
"${CMAKE_CURRENT_SOURCE_DIR}/test/main.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/test/ECS/EcsTests.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/test/ECS/EcsFixture.cpp"
)
add_executable(
Tests
"${SOURCE_CODE}"
"${TEST_CODE}"
)
target_link_libraries(Tests GTest::gtest_main)
target_link_libraries(Tests ${CONAN_LIBS})
target_link_libraries(Tests gcov)
include(GoogleTest)
gtest_discover_tests(Tests)
endfunction()
if(TESTMODE EQUAL 1)
message("=== Unit Tests ===")
set(CMAKE_CXX_FLAGS "--coverage")
set(CMAKE_EXE_LINKER_FLAGS "--coverage")
add_compile_definitions(GTEST)
build_tests()
else()
message("==== Programs ====")
build_client()
build_server()
build_createFile()
endif()