-
Notifications
You must be signed in to change notification settings - Fork 188
/
CMakeLists.txt
385 lines (353 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
383
384
385
Project (Flare)
cmake_minimum_required (VERSION 2.8.12)
Set (PACKAGE "FLARE")
Set (VERSION "1.14")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
# can't use add_compile_options here. Seems to have something to do with add_compile_options appending it after the "-O3 -DNDEBUG" flags
if (MINGW AND CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_CXX_FLAGS_RELEASE "-Wl,-subsystem,windows ${CMAKE_CXX_FLAGS_RELEASE}")
endif()
# Default definitions
if (MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
else ()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-Wno-psabi)
endif()
add_compile_options(
-Wall -Wextra -Wunused -Wshadow -Woverloaded-virtual -Wunreachable-code -Wconversion -Wno-sign-conversion -Wformat-security
-fno-math-errno -fno-exceptions
-std=c++98
)
endif ()
add_compile_options(
"$<$<CONFIG:RELEASE>:-O2>"
"$<$<CONFIG:RELEASE>:-g0>"
"$<$<CONFIG:RELWITHDEBINFO>:-O2>"
"$<$<CONFIG:RELWITHDEBINFO>:-g>"
"$<$<CONFIG:MINSIZEREL>:-Os>"
"$<$<CONFIG:MINSIZEREL>:-g0>"
"$<$<CONFIG:DEBUG>:-O0>"
"$<$<CONFIG:DEBUG>:-g3>"
"$<$<CONFIG:DEBUG>:-pg>"
)
# Not supported by CMake 3.12!
# Travis uses this version so we have to stick to modifying the strings...
# add_link_options(
# "$<$<CONFIG:DEBUG>:-pg>"
# )
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "-pg ${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "-pg ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "-pg ${CMAKE_MODULE_LINKER_FLAGS_DEBUG}")
endif()
set(BINDIR "games" CACHE STRING "Directory from CMAKE_INSTALL_PREFIX where game executable will be installed.")
set(DATADIR "share/games/flare" CACHE STRING "Directory from CMAKE_INSTALL_PREFIX where game data files will be installed.")
set(MANDIR "share/man" CACHE STRING "Directory from CMAKE_INSTALL_PREFIX where manual pages will be installed.")
If(NOT IS_ABSOLUTE "${BINDIR}")
set(FLARE_EXECUTABLE_PATH ${CMAKE_INSTALL_PREFIX}/${BINDIR}/flare)
Else(NOT IS_ABSOLUTE "${BINDIR}")
set(FLARE_EXECUTABLE_PATH ${BINDIR}/flare)
EndIf(NOT IS_ABSOLUTE "${BINDIR}")
If(NOT IS_ABSOLUTE "${DATADIR}")
add_definitions(-DDATA_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}/${DATADIR}")
Else(NOT IS_ABSOLUTE "${DATADIR}")
add_definitions(-DDATA_INSTALL_DIR="${DATADIR}")
EndIf(NOT IS_ABSOLUTE "${DATADIR}")
# desktop file
If(NOT IS_ABSOLUTE "${BINDIR}")
set(FLARE_EXECUTABLE_PATH ${CMAKE_INSTALL_PREFIX}/${BINDIR}/flare)
Else(NOT IS_ABSOLUTE "${BINDIR}")
set(FLARE_EXECUTABLE_PATH ${BINDIR}/flare)
EndIf(NOT IS_ABSOLUTE "${BINDIR}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/distribution/flare.desktop.in" "${CMAKE_CURRENT_BINARY_DIR}/flare.desktop")
# Detect missing dependencies
# First, search for SDL2 modules
Find_Package(SDL2)
If (NOT SDL2_FOUND)
Message (FATAL_ERROR "Couldn't find SDL2 development files. On Debian-based systems (such as Ubuntu) you should install the 'libsdl2-dev' package.")
Else (NOT SDL2_FOUND)
INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR})
EndIf (NOT SDL2_FOUND)
Find_Package(SDL2_image)
If (NOT SDL2IMAGE_FOUND)
Message (FATAL_ERROR "Couldn't find SDL2-image development files. On Debian-based systems (such as Ubuntu) you should install the 'libsdl2-image-dev' package.")
Else (NOT SDL2IMAGE_FOUND)
INCLUDE_DIRECTORIES(${SDL2IMAGE_INCLUDE_DIR})
EndIf (NOT SDL2IMAGE_FOUND)
Find_Package(SDL2_mixer)
If (NOT SDL2MIXER_FOUND)
Message (FATAL_ERROR "Couldn't find SDL2-mixer development files. On Debian-based systems (such as Ubuntu) you should install the 'libsdl2-mixer-dev' package.")
Else (NOT SDL2MIXER_FOUND)
INCLUDE_DIRECTORIES(${SDL2MIXER_INCLUDE_DIR})
EndIf (NOT SDL2MIXER_FOUND)
Find_Package(SDL2_ttf)
If (NOT SDL2TTF_FOUND)
Message (FATAL_ERROR "Couldn't find SDL2-ttf development files. On Debian-based systems (such as Ubuntu) you should install the 'libsdl2-ttf-dev' package.")
Else (NOT SDL2TTF_FOUND)
INCLUDE_DIRECTORIES(${SDL2TTF_INCLUDE_DIR})
EndIf (NOT SDL2TTF_FOUND)
# Sources
Set (FLARE_SOURCES
./src/Animation.cpp
./src/AnimationMedia.cpp
./src/AnimationManager.cpp
./src/AnimationSet.cpp
./src/AStarContainer.cpp
./src/AStarNode.cpp
./src/Avatar.cpp
./src/Camera.cpp
./src/CampaignManager.cpp
./src/CombatText.cpp
./src/CursorManager.cpp
./src/DeviceList.cpp
./src/EffectManager.cpp
./src/EnemyGroupManager.cpp
./src/EngineSettings.cpp
./src/Entity.cpp
./src/EntityBehavior.cpp
./src/EntityManager.cpp
./src/EventManager.cpp
./src/FileParser.cpp
./src/FogOfWar.cpp
./src/FontEngine.cpp
./src/GameSlotPreview.cpp
./src/GameState.cpp
./src/GameStateConfig.cpp
./src/GameStateCutscene.cpp
./src/GameStateTitle.cpp
./src/GameStateLoad.cpp
./src/GameStatePlay.cpp
./src/GameStateNew.cpp
./src/GameSwitcher.cpp
./src/GetText.cpp
./src/Hazard.cpp
./src/HazardManager.cpp
./src/IconManager.cpp
./src/InputState.cpp
./src/ItemManager.cpp
./src/ItemStorage.cpp
./src/Loot.cpp
./src/LootManager.cpp
./src/Map.cpp
./src/MapParallax.cpp
./src/MapCollision.cpp
./src/MapRenderer.cpp
./src/Menu.cpp
./src/MenuActionBar.cpp
./src/MenuActiveEffects.cpp
./src/MenuBook.cpp
./src/MenuCharacter.cpp
./src/MenuConfig.cpp
./src/MenuConfirm.cpp
./src/MenuDevConsole.cpp
./src/MenuEnemy.cpp
./src/MenuExit.cpp
./src/MenuGameOver.cpp
./src/MenuHUDLog.cpp
./src/MenuInventory.cpp
./src/MenuItemStorage.cpp
./src/MenuLog.cpp
./src/MenuManager.cpp
./src/MenuMiniMap.cpp
./src/MenuMovementType.cpp
./src/MenuNumPicker.cpp
./src/MenuPowers.cpp
./src/MenuStash.cpp
./src/MenuStatBar.cpp
./src/MenuTalker.cpp
./src/MenuTouchControls.cpp
./src/MenuVendor.cpp
./src/MessageEngine.cpp
./src/ModManager.cpp
./src/NPC.cpp
./src/NPCManager.cpp
./src/PowerManager.cpp
./src/QuestLog.cpp
./src/RenderDevice.cpp
./src/SaveLoad.cpp
./src/SDLInputState.cpp
./src/SDLSoftwareRenderDevice.cpp
./src/SDLSoundManager.cpp
./src/SDLHardwareRenderDevice.cpp
./src/SDLFontEngine.cpp
./src/Settings.cpp
./src/SharedGameResources.cpp
./src/SharedResources.cpp
./src/SoundManager.cpp
./src/StatBlock.cpp
./src/Stats.cpp
./src/Subtitles.cpp
./src/TileSet.cpp
./src/TooltipData.cpp
./src/TooltipManager.cpp
./src/Utils.cpp
./src/UtilsDebug.cpp
./src/UtilsFileSystem.cpp
./src/UtilsParsing.cpp
./src/Version.cpp
./src/Widget.cpp
./src/WidgetCheckBox.cpp
./src/WidgetButton.cpp
./src/WidgetHorizontalList.cpp
./src/WidgetInput.cpp
./src/WidgetLabel.cpp
./src/WidgetListBox.cpp
./src/WidgetLog.cpp
./src/WidgetScrollBar.cpp
./src/WidgetScrollBox.cpp
./src/WidgetSlider.cpp
./src/WidgetSlot.cpp
./src/WidgetTabControl.cpp
./src/WidgetTooltip.cpp
./src/XPScaling.cpp
./src/main.cpp
)
Set (FLARE_HEADERS
./src/Animation.h
./src/AnimationMedia.h
./src/AnimationManager.h
./src/AnimationSet.h
./src/AStarContainer.h
./src/AStarNode.h
./src/Avatar.h
./src/Camera.h
./src/CampaignManager.h
./src/CombatText.h
./src/CommonIncludes.h
./src/CursorManager.h
./src/DeviceList.h
./src/EffectManager.h
./src/EnemyGroupManager.h
./src/EngineSettings.h
./src/Entity.h
./src/EntityBehavior.h
./src/EntityManager.h
./src/EventManager.h
./src/FileParser.h
./src/FogOfWar.h
./src/FontEngine.h
./src/GameSlotPreview.h
./src/GameState.h
./src/GameStateConfig.h
./src/GameStateCutscene.h
./src/GameStateTitle.h
./src/GameStateLoad.h
./src/GameStatePlay.h
./src/GameStateNew.h
./src/GameSwitcher.h
./src/GetText.h
./src/Hazard.h
./src/HazardManager.h
./src/IconManager.h
./src/InputState.h
./src/ItemManager.h
./src/ItemStorage.h
./src/Loot.h
./src/LootManager.h
./src/Map.h
./src/MapParallax.h
./src/MapCollision.h
./src/MapRenderer.h
./src/Menu.h
./src/MenuActionBar.h
./src/MenuActiveEffects.h
./src/MenuBook.h
./src/MenuCharacter.h
./src/MenuConfig.h
./src/MenuConfirm.h
./src/MenuDevConsole.h
./src/MenuEnemy.h
./src/MenuExit.h
./src/MenuGameOver.h
./src/MenuHUDLog.h
./src/MenuInventory.h
./src/MenuItemStorage.h
./src/MenuLog.h
./src/MenuManager.h
./src/MenuMiniMap.h
./src/MenuMovementType.h
./src/MenuNumPicker.h
./src/MenuPowers.h
./src/MenuStash.h
./src/MenuStatBar.h
./src/MenuTalker.h
./src/MenuTouchControls.h
./src/MenuVendor.h
./src/MessageEngine.h
./src/ModManager.h
./src/NPC.h
./src/NPCManager.h
./src/PowerManager.h
./src/QuestLog.h
./src/RenderDevice.h
./src/SDLInputState.h
./src/SDLSoftwareRenderDevice.h
./src/SDLSoundManager.h
./src/SDLHardwareRenderDevice.h
./src/SDLFontEngine.h
./src/Settings.h
./src/SharedGameResources.h
./src/SharedResources.h
./src/StatBlock.h
./src/Stats.h
./src/SoundManager.h
./src/Subtitles.h
./src/TileSet.h
./src/TooltipData.h
./src/TooltipManager.h
./src/Utils.h
./src/UtilsDebug.h
./src/UtilsFileSystem.h
./src/UtilsMath.h
./src/UtilsParsing.h
./src/Version.h
./src/Widget.h
./src/WidgetCheckBox.h
./src/WidgetButton.h
./src/WidgetHorizontalList.h
./src/WidgetInput.h
./src/WidgetLabel.h
./src/WidgetListBox.h
./src/WidgetLog.h
./src/WidgetScrollBar.h
./src/WidgetScrollBox.h
./src/WidgetSlider.h
./src/WidgetSlot.h
./src/WidgetTabControl.h
./src/WidgetTooltip.h
./src/XPScaling.h
)
# Add icon and file info to executable for Windows systems
IF (WIN32)
SET(FLARE_SOURCES
${FLARE_SOURCES}
./src/Flare.rc
)
ENDIF (WIN32)
Add_Executable (flare ${FLARE_SOURCES} ${FLARE_HEADERS})
# libSDLMain comes with libSDL if needed on certain platforms
If (NOT SDL2MAIN_LIBRARY)
Set (SDL2MAIN_LIBRARY "")
EndIf (NOT SDL2MAIN_LIBRARY)
Target_Link_Libraries (flare ${CMAKE_LD_FLAGS} ${SDL2_LIBRARY} ${SDL2IMAGE_LIBRARY} ${SDL2MIXER_LIBRARY} ${SDL2TTF_LIBRARY} ${SDL2MAIN_LIBRARY})
# installing to the proper places
install(PROGRAMS
${CMAKE_CURRENT_BINARY_DIR}/flare
DESTINATION ${BINDIR})
install(DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}/mods"
DESTINATION ${DATADIR})
install(FILES
"${CMAKE_CURRENT_SOURCE_DIR}/distribution/flare.man"
DESTINATION ${MANDIR}/man6
RENAME flare.6)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/flare.desktop"
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)
install(FILES
"${CMAKE_CURRENT_SOURCE_DIR}/distribution/flare_logo_icon.svg"
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps
RENAME flare.svg)