forked from julillae/minos-monster-maze
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
260 lines (231 loc) · 9.02 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.1)
project(436d)
# Set c++11
# https://stackoverflow.com/questions/10851247/how-to-activate-c-11-in-cmake
if (POLICY CMP0025)
cmake_policy(SET CMP0025 NEW)
endif ()
set (CMAKE_CXX_STANDARD 11)
# nice hierarchichal structure in MSVC
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
#Find OS
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(IS_OS_MAC 1)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(IS_OS_LINUX 1)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(IS_OS_WINDOWS 1)
else()
message(FATAL_ERROR "OS ${CMAKE_SYSTEM_NAME} was not recognized")
endif()
# Create executable target
# You can switch to use the file GLOB for simplicity but at your own risk
# file(GLOB SOURCE_FILES src/*.cpp src/*.hpp)
set(SOURCE_FILES
src/a1.cpp
src/common.cpp
src/renderManager.cpp
src/spriteSheet.cpp
src/characters/character.cpp
src/characters/player.cpp
src/characters/enemy.cpp
src/characters/smart.cpp
src/characters/harpy.cpp
src/characters/simple.cpp
src/characters/spider.cpp
src/characters/minotaur.cpp
src/mazeComponents/mazeComponent.cpp
src/mazeComponents/fixedComponent.cpp
src/mazeComponents/freeComponent.cpp
src/mazeComponents/geometricComponent.cpp
src/mazeComponents/floor.cpp
src/mazeComponents/fire.cpp
src/mazeComponents/ice.cpp
src/mazeComponents/exit.cpp
src/mazeComponents/spike.cpp
src/mazeComponents/blade.cpp
src/gameAI.cpp
src/physics.cpp
src/level.cpp
src/stateTree.cpp
src/menus/helpMenu.cpp
src/game.cpp
src/gameStates/gameState.cpp
src/gameStates/mainMenuState.cpp
src/gameStates/levelSelectState.cpp
src/gameStates/pauseMenuState.cpp
src/gameStates/creditsState.cpp
src/gameStates/introState.cpp
src/gameStates/minotaurIntroState.cpp
src/menus/mainMenu.cpp
src/menus/menu.cpp
src/menus/button.cpp
src/menus/levelSelectMenu.cpp
src/menus/levelButton.cpp
src/menus/mainButton.cpp
src/menus/pauseMenu.cpp
src/menus/savePopup.cpp
src/menus/credits.cpp
src/menus/intro.cpp
src/menus/minotaurIntro.cpp
src/levelLoader.cpp
src/flashMessage.cpp
src/gameSave.cpp
src/quadTree.cpp
src/soundManager.cpp
src/timer.cpp
src/rotationUI.cpp
src/rotationUIEnergy.cpp
src/particleSystem/particle.cpp
src/particleSystem/emitter.cpp
src/textManager.cpp
include/common.hpp
include/renderManager.hpp
include/spriteSheet.hpp
include/characters/character.hpp
include/characters/player.hpp
include/characters/enemy.hpp
include/characters/smart.hpp
include/characters/harpy.hpp
include/characters/simple.hpp
include/characters/spider.hpp
include/characters/minotaur.hpp
include/mazeComponents/mazeComponent.hpp
include/mazeComponents/fixedComponent.hpp
include/mazeComponents/freeComponent.hpp
include/mazeComponents/geometricComponent.hpp
include/mazeComponents/floor.hpp
include/mazeComponents/ice.hpp
include/mazeComponents/fire.hpp
include/mazeComponents/exit.hpp
include/mazeComponents/spike.hpp
include/mazeComponents/blade.hpp
include/gameAI.hpp
include/physics.hpp
include/level.hpp
include/stateTree.hpp
include/menus/helpMenu.hpp
include/game.hpp
include/gameStates/gameState.hpp
include/gameStates/mainMenuState.hpp
include/gameStates/levelSelectState.hpp
include/gameStates/pauseMenuState.hpp
include/gameStates/creditsState.hpp
include/gameStates/introState.hpp
include/gameStates/minotaurIntroState.hpp
include/menus/mainMenu.hpp
include/menus/menu.hpp
include/menus/button.hpp
include/menus/levelSelectMenu.hpp
include/menus/levelButton.hpp
include/menus/mainButton.hpp
include/menus/pauseMenu.hpp
include/menus/savePopup.hpp
include/menus/credits.hpp
include/menus/intro.hpp
include/menus/minotaurIntro.hpp
include/levelLoader.hpp
include/flashMessage.hpp
include/gameSave.hpp
include/quadTree.hpp
include/soundManager.hpp
include/timer.hpp
include/rotationUI.hpp
include/rotationUIEnergy.hpp
include/particleSystem/particle.hpp
include/particleSystem/emitter.hpp
include/textManager.hpp
)
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
target_include_directories(${PROJECT_NAME} PUBLIC src/)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/levels
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
# Added this so policy CMP0065 doesn't scream
set_target_properties(${PROJECT_NAME} PROPERTIES ENABLE_EXPORTS 0)
# External header-only libraries in the ext/
target_include_directories(${PROJECT_NAME} PUBLIC ext/stb_image/)
target_include_directories(${PROJECT_NAME} PUBLIC ext/gl3w)
target_include_directories(${PROJECT_NAME} PUBLIC ext/rapidjson)
target_include_directories(${PROJECT_NAME} PUBLIC ext/freetype/include)
# Find OpenGL
find_package(OpenGL REQUIRED)
if (OPENGL_FOUND)
target_include_directories(${PROJECT_NAME} PUBLIC ${OPENGL_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} PUBLIC ${OPENGL_gl_LIBRARY})
endif()
# glfw, sdl could be precompiled (on windows) or installed by a package manager (on OSX and Linux)
if (IS_OS_LINUX OR IS_OS_MAC)
# Try to find packages rather than to use the precompiled ones
# Since we're on OSX or Linux, we can just use pkgconfig.
find_package(PkgConfig REQUIRED)
pkg_search_module(GLFW REQURIED glfw3)
pkg_search_module(SDL2 REQURIED sdl2)
pkg_search_module(SDL2MIXER REQURIED SDL2_mixer)
pkg_search_module(FREETYPE REQUIRED freetype2)
# Link Frameworks on OSX
if (IS_OS_MAC)
find_library(COCOA_LIBRARY Cocoa)
find_library(CF_LIBRARY CoreFoundation)
target_link_libraries(${PROJECT_NAME} PUBLIC ${COCOA_LIBRARY} ${CF_LIBRARY} ${FREETYPE_LIBRARIES})
endif()
elseif (IS_OS_WINDOWS)
# https://stackoverflow.com/questions/17126860/cmake-link-precompiled-library-depending-on-os-and-architecture
set(GLFW_FOUND TRUE)
set(SDL2_FOUND TRUE)
set(FREETYPE_FOUND TRUE)
set(GLFW_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/ext/glfw/include")
set(SDL2_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/ext/sdl/include/SDL")
set(FREETYPE_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/ext/freetype/include/freetype")
if (${CMAKE_SIZEOF_VOID_P} MATCHES "8")
set(GLFW_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/ext/glfw/lib/glfw3dll-x64.lib")
set(SDL2_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/ext/sdl/lib/SDL2-x64.lib")
set(SDL2MIXER_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/ext/sdl/lib/SDL2_mixer-x64.lib")
set(FREETYPE_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/ext/freetype/win64/freetype.lib")
set(GLFW_DLL "${CMAKE_CURRENT_SOURCE_DIR}/ext/glfw/lib/glfw3-x64.dll")
set(SDL_DLL "${CMAKE_CURRENT_SOURCE_DIR}/ext/sdl/lib/SDL2-x64.dll")
set(SDLMIXER_DLL "${CMAKE_CURRENT_SOURCE_DIR}/ext/sdl/lib/SDL2_mixer-x64.dll")
set(FREETYPE_DLL "${CMAKE_CURRENT_SOURCE_DIR}/ext/freetype/win64/freetype.dll")
else()
set(GLFW_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/ext/glfw/lib/glfw3dll-x86.lib")
set(SDL2_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/ext/sdl/lib/SDL2-x86.lib")
set(SDL2MIXER_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/ext/sdl/lib/SDL2_mixer-x86.lib")
set(FREETYPE_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/ext/freetype/win32/freetype.lib")
set(GLFW_DLL "${CMAKE_CURRENT_SOURCE_DIR}/ext/glfw/lib/glfw3-x86.dll")
set(SDL_DLL "${CMAKE_CURRENT_SOURCE_DIR}/ext/sdl/lib/SDL2-x86.dll")
set(SDLMIXER_DLL "${CMAKE_CURRENT_SOURCE_DIR}/ext/sdl/lib/SDL2_mixer-x86.dll")
set(FREETYPE_DLL "${CMAKE_CURRENT_SOURCE_DIR}/ext/freetype/win32/freetype.dll")
endif()
# Copy and rename dlls
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${GLFW_DLL}"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/glfw3.dll")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${SDL_DLL}"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/SDL2.dll")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${SDLMIXER_DLL}"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/SDL2_mixer.dll")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${FREETYPE_DLL}"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/freetype.dll")
endif()
# Can't find the include and lib. Quit.
if (NOT GLFW_FOUND OR NOT SDL2_FOUND)
if (NOT GLFW_FOUND)
message(FATAL_ERROR "Can't find GLFW." )
else ()
message(FATAL_ERROR "Can't find SDL." )
endif()
endif()
target_include_directories(${PROJECT_NAME} PUBLIC ${GLFW_INCLUDE_DIRS})
target_include_directories(${PROJECT_NAME} PUBLIC ${SDL2_INCLUDE_DIRS})
target_include_directories(${PROJECT_NAME} PUBLIC ${FREETYPE_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} PUBLIC ${GLFW_LIBRARIES} ${SDL2_LIBRARIES} ${SDL2MIXER_LIBRARIES} ${FREETYPE_LIBRARIES})
# Needed to add this
if(IS_OS_LINUX)
target_link_libraries(${PROJECT_NAME} PUBLIC ${CMAKE_DL_LIBS})
endif()