-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
242 lines (217 loc) · 7.05 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
Project (Flare)
cmake_minimum_required (VERSION 2.6)
Set (PACKAGE "FLARE")
Set (VERSION "0.19")
option(USE_SDL2 "USE_SDL2" OFF)
if (USE_SDL2)
add_definitions(-DUSE_SDL2)
endif (USE_SDL2)
# Default definitions
if (NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wunused -Wshadow -Woverloaded-virtual -Wunreachable-code")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-math-errno -fno-exceptions")
if (NOT CMAKE_CXX_COMPILER MATCHES "clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math")
endif (NOT CMAKE_CXX_COMPILER MATCHES "clang")
set(CMAKE_LD_FLAGS "-fwhole-program")
endif (NOT MSVC)
if (CMAKE_CXX_COMPILER MATCHES "clang")
# clang needs lstdc++ linked explicitly:
set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -lstdc++")
elseif ()
# assume gcc:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-enforce-eh-specs")
endif ()
if(CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -g0")
elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
elseif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -g0")
elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -pg")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "-pg")
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "-pg")
set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "-pg")
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}")
# Detect missing dependencies
If (USE_SDL2)
Include(FindPkgConfig)
PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2)
INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS})
PKG_SEARCH_MODULE(SDL2IMAGE REQUIRED SDL2_image)
INCLUDE_DIRECTORIES(${SDL2IMAGE_INCLUDE_DIRS})
PKG_SEARCH_MODULE(SDL2MIXER REQUIRED SDL2_mixer)
INCLUDE_DIRECTORIES(${SDL2MIXER_INCLUDE_DIRS})
PKG_SEARCH_MODULE(SDL2TTF REQUIRED SDL2_ttf)
INCLUDE_DIRECTORIES(${SDL2TTF_INCLUDE_DIRS})
Else (USE_SDL2)
Find_Package (SDL REQUIRED)
If (NOT SDL_FOUND)
Message (FATAL_ERROR "Couldn't find SDL development files. On Debian-based systems (such as Ubuntu) you should install the 'libsdl1.2-dev' package.")
Else (NOT SDL_FOUND)
Include_Directories (${SDL_INCLUDE_DIR})
EndIf (NOT SDL_FOUND)
Find_Package (SDL_mixer REQUIRED)
If (NOT SDLMIXER_FOUND)
Message (FATAL_ERROR "Couldn't find SDL-mixer development files. On Debian-based systems (such as Ubuntu) you should install the 'libsdl-mixer1.2-dev' package.")
Else (NOT SDLMIXER_FOUND)
Include_Directories (${SDLMIXER_INCLUDE_DIR})
EndIf (NOT SDLMIXER_FOUND)
Find_Package (SDL_image REQUIRED)
If (NOT SDLIMAGE_FOUND)
Message (FATAL_ERROR "Couldn't find SDL-image development files. On Debian-based systems (such as Ubuntu) you should install the 'libsdl-image1.2-dev' package.")
Else (NOT SDLIMAGE_FOUND)
Include_Directories (${SDLIMAGE_INCLUDE_DIR})
EndIf (NOT SDLIMAGE_FOUND)
Find_Package (SDL_ttf REQUIRED)
If (NOT SDLTTF_FOUND)
Message (FATAL_ERROR "Couldn't find SDL-ttf development files. On Debian-based systems (such as Ubuntu) you should install the 'libsdl-ttf2.0-dev' package.")
Else (NOT SDLTTF_FOUND)
Include_Directories (${SDLTTF_INCLUDE_DIR})
EndIf (NOT SDLTTF_FOUND)
EndIf (USE_SDL2)
# Sources
if (USE_SDL2)
Set (FLARE_SOURCES ./src/SDL2RenderDevice.cpp)
else (USE_SDL2)
Set (FLARE_SOURCES
./src/SDL_gfxBlitFunc.c
./src/SDLRenderDevice.cpp
)
endif(USE_SDL2)
Set (FLARE_SOURCES
${FLARE_SOURCES}
./src/BehaviorAlly.cpp
./src/Entity.cpp
./src/Animation.cpp
./src/AnimationManager.cpp
./src/AnimationSet.cpp
./src/AStarContainer.cpp
./src/AStarNode.cpp
./src/Avatar.cpp
./src/BehaviorStandard.cpp
./src/CampaignManager.cpp
./src/CombatText.cpp
./src/EffectManager.cpp
./src/Enemy.cpp
./src/EnemyBehavior.cpp
./src/EnemyGroupManager.cpp
./src/EnemyManager.cpp
./src/EventManager.cpp
./src/FileParser.cpp
./src/FontEngine.cpp
./src/GameState.cpp
./src/GameStateConfig.cpp
./src/GameStateCutscene.cpp
./src/GameStateTitle.cpp
./src/GameStateLoad.cpp
./src/GameStatePlay.cpp
./src/GameStateResolution.cpp
./src/GameStateNew.cpp
./src/GameSwitcher.cpp
./src/GetText.cpp
./src/Hazard.cpp
./src/HazardManager.cpp
./src/ImageManager.cpp
./src/InputState.cpp
./src/ItemManager.cpp
./src/ItemStorage.cpp
./src/Loot.cpp
./src/LootManager.cpp
./src/Map.cpp
./src/MapCollision.cpp
./src/MapRenderer.cpp
./src/Menu.cpp
./src/MenuActionBar.cpp
./src/MenuActiveEffects.cpp
./src/MenuCharacter.cpp
./src/MenuConfirm.cpp
./src/MenuEnemy.cpp
./src/MenuExit.cpp
./src/MenuHUDLog.cpp
./src/MenuInventory.cpp
./src/MenuItemStorage.cpp
./src/MenuLog.cpp
./src/MenuManager.cpp
./src/MenuMiniMap.cpp
./src/MenuNPCActions.cpp
./src/MenuPowers.cpp
./src/MenuStash.cpp
./src/MenuStatBar.cpp
./src/MenuTalker.cpp
./src/MenuVendor.cpp
./src/MessageEngine.cpp
./src/ModManager.cpp
./src/NPC.cpp
./src/NPCManager.cpp
./src/PowerManager.cpp
./src/QuestLog.cpp
./src/SaveLoad.cpp
./src/Settings.cpp
./src/SharedGameResources.cpp
./src/SharedResources.cpp
./src/StatBlock.cpp
./src/Stats.cpp
./src/SoundManager.cpp
./src/TileSet.cpp
./src/TooltipData.cpp
./src/Utils.cpp
./src/UtilsDebug.cpp
./src/UtilsFileSystem.cpp
./src/UtilsParsing.cpp
./src/Widget.cpp
./src/WidgetCheckBox.cpp
./src/WidgetButton.cpp
./src/WidgetInput.cpp
./src/WidgetLabel.cpp
./src/WidgetListBox.cpp
./src/WidgetScrollBar.cpp
./src/WidgetScrollBox.cpp
./src/WidgetSlider.cpp
./src/WidgetSlot.cpp
./src/WidgetTabControl.cpp
./src/WidgetTooltip.cpp
./src/main.cpp
)
# 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})
# libSDLMain comes with libSDL if needed on certain platforms
If (NOT SDLMAIN_LIBRARY)
Set (SDLMAIN_LIBRARY "")
EndIf (NOT SDLMAIN_LIBRARY)
If (USE_SDL2)
Target_Link_Libraries (flare ${CMAKE_LD_FLAGS} ${SDL2_LIBRARIES} ${SDL2IMAGE_LIBRARIES} ${SDL2MIXER_LIBRARIES} ${SDL2TTF_LIBRARIES})
Else (USE_SDL2)
Target_Link_Libraries (flare ${CMAKE_LD_FLAGS} ${SDL_LIBRARY} ${SDLMIXER_LIBRARY} ${SDLIMAGE_LIBRARY} ${SDLTTF_LIBRARY} ${SDLMAIN_LIBRARY})
EndIF (USE_SDL2)
# installing to the proper places
install(PROGRAMS
${CMAKE_CURRENT_BINARY_DIR}/flare
DESTINATION ${BINDIR})
install(DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}/mods"
DESTINATION ${DATADIR}/default)
install(FILES
"${CMAKE_CURRENT_SOURCE_DIR}/distribution/flare.man"
DESTINATION ${MANDIR}/man1
RENAME flare.1)