-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
260 lines (190 loc) · 8.07 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
cmake_minimum_required(VERSION 3.9.3)
project(WhispererEngine)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Add the compiler flag
set(HYPOT_FLAG "-D_hypot=hypot")
add_definitions(${HYPOT_FLAG})
# Determine platform specific libs
if(WIN32)
set(PLATFORM_LIBS wsock32 ws2_32)
else()
set(PLATFORM_LIBS "")
endif()
link_libraries(${PLATFORM_LIBS})
# Download catch test framework
configure_file(libs/catch/CMakeLists.txt catch-download/CMakeLists.txt)
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/catch-download")
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/catch-download")
# Download pybind11
configure_file(libs/pybind11/CMakeLists.txt pybind11-download/CMakeLists.txt)
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/pybind11-download")
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/pybind11-download")
# Download json
configure_file(libs/json/CMakeLists.txt json-download/CMakeLists.txt)
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/json-download")
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/json-download")
# Include downloaded directories
include_directories(${CMAKE_BINARY_DIR}/catch-src)
add_subdirectory(${CMAKE_BINARY_DIR}/pybind11-src)
include_directories(${CMAKE_BINARY_DIR}/json-src/single_include)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.65.1 REQUIRED system thread)
# Include boost directories
include_directories(${Boost_INCLUDE_DIRS})
link_libraries(${Boost_LIBRARIES})
# Find Postgres
find_package(PostgreSQL 9.6.7 REQUIRED)
# Inclue and link Postgres
include_directories(${PostgreSQL_INCLUDE_DIRS})
link_libraries(${PostgreSQL_LIBRARIES})
# Find CURL
find_package(CURL REQUIRED)
# Include and link CURL
include_directories(${CURL_INCLUDE_DIRS})
link_libraries(${CURL_LIBRARIES})
# Add pybind11 modules
set(PYBIND11_CPP_STANDARD -std=c++17)
#pybind11_add_module(<module name> [<module source files>, ...])
pybind11_add_module(Whisperer
include/Game/Python/Module.h
src/Game/Card.cpp
src/Game/Mana.cpp
src/Game/Utilities/Taggable.cpp
src/Game/Utilities/Exportable.cpp
src/Game/Card/Constant.cpp
src/Game/Card/Creature.cpp)
# Define the default libraries to include with the targets
set(DEFAULT_LIBS pybind11::embed ${Boost_LIBRARIES})
# All the headers and source code for classes used in the core game
set(WHISPERER_FILES
src/Game/Modifier.cpp
include/Game/Modifier.h
src/Game/Board.cpp
include/Game/Board.h
src/Game/Card.cpp
include/Game/Card.h
src/Game/Container.cpp
include/Game/Container.h
src/Game/Effect.cpp
include/Game/Effect.h
src/Game/Event.cpp
include/Game/Event.h
src/Game/Game.cpp
include/Game/Game.h
src/Game/Mana.cpp
include/Game/Mana.h
src/Game/Player.cpp
include/Game/Player.h
src/Game/Container/Deck.cpp
include/Game/Container/Deck.h
src/Game/Container/Graveyard.cpp
include/Game/Container/Graveyard.h
src/Game/Container/Hand.cpp
include/Game/Container/Hand.h
src/Game/Container/CreatureZone.cpp
include/Game/Container/CreatureZone.h
src/Game/Card/Constant.cpp
include/Game/Card/Constant.h
src/Game/Card/Creature.cpp
include/Game/Card/Creature.h
src/Game/Card/Spell.cpp
include/Game/Card/Spell.h
src/Game/Event/Game/CreatureDestroyedEvent.cpp
include/Game/Event/Game/CreatureDestroyedEvent.h
src/Game/Event/Game/EndGameEvent.cpp
include/Game/Event/Game/EndGameEvent.h
src/Game/Event/Game/EndTurnEvent.cpp
include/Game/Event/Game/EndTurnEvent.h
src/Game/Event/Game/StartGameEvent.cpp
include/Game/Event/Game/StartGameEvent.h
src/Game/Event/Game/StartTurnEvent.cpp
include/Game/Event/Game/StartTurnEvent.h
src/Game/Event/Player/CreatureAttackedEvent.cpp
include/Game/Event/Player/CreatureAttackedEvent.h
src/Game/Event/Player/DrawEvent.cpp
include/Game/Event/Player/DrawEvent.h
src/Game/Event/Player/PlayCardEvent.cpp
include/Game/Event/Player/PlayCardEvent.h
src/Game/Event/Player/PlayerAttackedEvent.cpp
include/Game/Event/Player/PlayerAttackedEvent.h
src/Game/Python/Factory.cpp
include/Game/Python/Factory.h
src/Game/Python/Version.cpp
include/Game/Python/Version.h
src/Network/Client.cpp
include/Network/Client.h
src/Network/Message.cpp
include/Network/Message.h
src/Network/Server.cpp
include/Network/Server.h
src/Network/HTTPRequest.cpp
include/Network/HTTPRequest.h
include/Network/Request/Lobby/AuthMessage.h
src/Network/Request/Lobby/AuthMessage.cpp
src/Network/Response/Game/CreatureAttackedMessage.cpp
include/Network/Response/Game/CreatureAttackedMessage.h
src/Network/Response/Game/CardMovedMessage.cpp
include/Network/Response/Game/CardMovedMessage.h
src/Network/Request/Game/ChatMessage.cpp
include/Network/Request/Game/ChatMessage.h
src/Network/Request/Game/FightCreatureMessage.cpp
include/Network/Request/Game/FightCreatureMessage.h
src/Network/Response/Game/DrawMessage.cpp
include/Network/Response/Game/DrawMessage.h
src/Network/Response/Game/EndGameMessage.cpp
include/Network/Response/Game/EndGameMessage.h
src/Network/Response/Game/EndTurnMessage.cpp
include/Network/Response/Game/EndTurnMessage.h
src/Network/Request/Game/FightPlayerMessage.cpp
include/Network/Request/Game/FightPlayerMessage.h
src/Network/Request/Game/PlayCardMessage.cpp
include/Network/Request/Game/PlayCardMessage.h
src/Network/Response/Game/PlayerAttackedMessage.cpp
include/Network/Response/Game/PlayerAttackedMessage.h
src/Network/Request/Lobby/QueueMessage.cpp
include/Network/Request/Lobby/QueueMessage.h
src/Network/Response/Game/StartGameMessage.cpp
include/Network/Response/Game/StartGameMessage.h
src/Network/Response/Game/StartTurnMessage.cpp
include/Network/Response/Game/StartTurnMessage.h
src/Network/Exceptions/JSONError.cpp
include/Network/Exceptions/JSONError.h
src/Game/Utilities/Taggable.cpp
include/Game/Utilities/Taggable.h
src/Game/Utilities/Exportable.cpp
include/Game/Utilities/Exportable.h
src/Game/Utilities/Database.cpp
include/Game/Utilities/Database.h)
# All source files and the entry point
set(SOURCE_FILES
src/WhispererEngine.cpp
${WHISPERER_FILES})
# Define the WhispererEngine target
add_executable(WhispererEngine ${SOURCE_FILES})
target_include_directories(WhispererEngine PRIVATE ${Boost_INCLUDE_DIRS})
target_link_libraries(WhispererEngine PRIVATE ${DEFAULT_LIBS} ${PLATFORM_LIBS} ${CMAKE_THREAD_LIBS_INIT})
# All headers and source files for the game, with the unit tests, and the catch main
set(TEST_FILES
${WHISPERER_FILES}
tests/CatchMain.cpp
tests/Game/test_Card.cpp
tests/Game/test_Player.cpp
tests/Game/Card/test_Creature.cpp
tests/Game/Python/test_Factory.cpp
tests/Game/Python/test_Integration.cpp
tests/Game/Utilities/test_Database.cpp
tests/Network/test_Message.cpp
tests/Network/test_HTTPRequest.cpp)
# Define the WhispererEngineTests target
add_executable(WhispererEngineTests ${TEST_FILES})
target_include_directories(WhispererEngineTests PRIVATE ${Boost_INCLUDE_DIRS})
target_link_libraries(WhispererEngineTests PRIVATE ${DEFAULT_LIBS} ${PLATFORM_LIBS} ${CMAKE_THREAD_LIBS_INIT})