-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
425 lines (344 loc) · 15.6 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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
# PROJECT DESCRIPTION
set(META_PROJECT_NAME "mammut")
set(META_VERSION_MAJOR "0")
set(META_VERSION_MINOR "0")
set(META_VERSION_PATCH "1")
set(META_VERSION "${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}")
set(META_AUTHOR_ORGANIZATION "mammut-group")
set(META_AUTHOR_DOMAIN "https://github.com/mjendruk/mammut")
# OPTIONS
option(OPTION_LIMIT_CONFIGS "Generate limited configs (Release; Debug)" ON)
option(OPTION_LOCAL_INSTALL "Install to a local directory instead of the system" OFF)
# CMAKE CONFIGURATION
set(MAMMUT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
# Include cmake modules from ./cmake
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# Set output directories
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
# Set configuration types
if(OPTION_LIMIT_CONFIGS)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Limited Configs" FORCE)
endif()
# Project
project(${META_PROJECT_NAME} C CXX)
# Generate folders
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Include custom cmake functions
include(cmake/Custom.cmake)
# PLATFORM AND ARCHITECTURE
# Architecture (32/64 bit)
set(X64 OFF)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(X64 ON)
endif()
# Check for linux
if(UNIX AND NOT APPLE)
set(LINUX 1)
endif()
# Setup platform specifics (compile flags, etc., ...)
if(MSVC)
message(STATUS "Configuring for platform Windows/MSVC.")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/PlatformWindowsMSVC.cmake)
elseif(WIN32 AND CMAKE_COMPILER_IS_GNUCXX)
message(STATUS "Configuring for platform Windows/GCC.")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/PlatformWindowsGCC.cmake)
elseif(LINUX AND CMAKE_COMPILER_IS_GNUCXX)
message(STATUS "Configuring for platform Linux/GCC.")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/PlatformLinuxGCC.cmake)
elseif(APPLE)
message(STATUS "Configuring for platform MacOS.")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/PlatformMacOS.cmake)
else()
# Unsupported system/compiler
message(WARNING "Unsupported platform/compiler combination")
endif()
# Install locations
set(project ${META_PROJECT_NAME})
if(WIN32)
set(INSTALL_BIN ".") # C:\Programme\<project>
set(INSTALL_SHARED ".") # C:\Programme\<project>
set(INSTALL_LIB "lib") # C:\Programme\<project>\lib
set(INSTALL_INCLUDE "include") # C:\Programme\<project>\include
set(INSTALL_DOC "doc") # C:\Programme\<project>\doc
set(INSTALL_APPLICATIONS "") # Not available under Windows
set(INSTALL_ICONS "") # Not available under Windows
set(INSTALL_INIT "") # Not available under Windows
set(INSTALL_DATA ".") # C:\Programme\<project>
set(INSTALL_EXAMPLES ".") # C:\Programme\<project>
elseif(LINUX OR APPLE)
set(INSTALL_BIN "bin") # /usr/[local]/bin
set(INSTALL_SHARED "lib") # /usr/[local]/lib
set(INSTALL_LIB "lib") # /usr/[local]/lib
set(INSTALL_INCLUDE "include") # /usr/[local]/include
set(INSTALL_DOC "share/doc/${project}") # /usr/[local]/share/doc/<project>
set(INSTALL_APPLICATIONS "share/applications") # /usr/[local]/share/applications
set(INSTALL_ICONS "share/pixmaps") # /usr/[local]/share/pixmaps
set(INSTALL_INIT "/etc/init") # /etc/init (upstart init scripts)
set(INSTALL_DATA "share/${project}") # /usr/[local]/share/<project>
set(INSTALL_EXAMPLES "share/${project}") # /usr/[local]/share/<project>
# Adjust target paths for Local installs
if(OPTION_LOCAL_INSTALL)
# Put binaries in root directory and keep data directory name
set(INSTALL_BIN ".") # /<INSTALL_PREFIX>
set(INSTALL_DATA ".") # /<INSTALL_PREFIX>
# We have to change the RPATH of binaries to achieve a usable local install.
# [TODO] For binaries, "$ORIGIN/lib" is right, so that libraries are found in ./lib.
# However, I have not yet tested what happens when libraries use other libraries.
# In that case, they might need the rpath $ORIGIN instead ...
set(CMAKE_SKIP_BUILD_RPATH FALSE) # Use automatic rpath for build
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) # Use specific rpath for INSTALL
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) # NO automatic rpath for INSTALL
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") # Libraries are relative to binary
endif()
endif()
# GET REPOSITORY VERSION
# Add a revision file containing the git-head tag for cpack and install
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
# Generate a shorter, googlelike variation for rev
string(SUBSTRING ${GIT_SHA1} 0 12 GIT_REV)
file(WRITE ${CMAKE_BINARY_DIR}/revision ${GIT_REV})
# [TODO] Really?? Do we want this deployed?
install(FILES ${CMAKE_BINARY_DIR}/revision DESTINATION .)
# [TODO] Deal with GIT-NOTFOUND
# Target
set(target mammut)
# Find externals
find_package(OpenGL REQUIRED)
find_package(GLM REQUIRED)
find_package(GLEW REQUIRED)
find_package(GLOW REQUIRED)
set(BULLET_ROOT $ENV{BULLET_ROOT})
find_package(BULLET REQUIRED)
find_package(FMOD REQUIRED)
set(CMAKE_AUTOMOC ON)
set(AUTOMOC_MOC_OPTIONS PROPERTIES FOLDER CMakeAutomocTargets)
# Probably works in the next cmake release -> http://www.cmake.org/Bug/view.php?id=13788
# What we do not want is automocs beside the project -> http://www.cmake.org/Bug/view.php?id=13688
set_property(GLOBAL PROPERTY AUTOMOC_FOLDER CMakeAutomocTargets)
# try to find either qt4 or qt5, favoring qt5
# good resource: http://www.kdab.com/using-cmake-with-qt-5/
# http://qt-project.org/forums/viewthread/30006/
if (WIN32)
cmake_policy(SET CMP0020 NEW)
endif()
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
set(source_path "${CMAKE_CURRENT_SOURCE_DIR}/source")
# Include directories
include_directories(
${CMAKE_BINARY_DIR} # for Meta.h
${OPENGL_INCLUDE_DIR}
${GLM_INCLUDE_DIR}
${GLEW_INCLUDE_DIR}
${GLOW_INCLUDE_DIR}
${BULLET_INCLUDE_DIRS}
${FMOD_INCLUDE_DIR}
${source_path}
)
# Generate meta-header
configure_file(${source_path}/mammut-version.h.in mammut-version.h)
set(sources
${source_path}/main.cpp
${source_path}/AbstractApplication.cpp
${source_path}/AbstractApplication.h
${source_path}/Game.cpp
${source_path}/Game.h
${source_path}/PerfCounter.cpp
${source_path}/PerfCounter.h
${source_path}/Util.cpp
${source_path}/Util.hpp
${source_path}/Util.h
${source_path}/logic/Mechanics.cpp
${source_path}/logic/Mechanics.h
${source_path}/3rdparty/tetgen/predicates.cxx
${source_path}/3rdparty/tetgen/tetgen.cxx
${source_path}/3rdparty/tetgen/tetgen.h
${source_path}/logic/highscore/HighscoreList.cpp
${source_path}/logic/highscore/HighscoreList.h
${source_path}/logic/highscore/HighscoreEntry.cpp
${source_path}/logic/highscore/HighscoreEntry.h
${source_path}/logic/menu/ControlsMenu.cpp
${source_path}/logic/menu/ControlsMenu.h
${source_path}/logic/menu/CreditsMenu.cpp
${source_path}/logic/menu/CreditsMenu.h
${source_path}/logic/menu/GameOverMenu.cpp
${source_path}/logic/menu/GameOverMenu.h
${source_path}/logic/menu/HighscoreMenu.cpp
${source_path}/logic/menu/HighscoreMenu.h
${source_path}/logic/menu/MainMenu.cpp
${source_path}/logic/menu/MainMenu.h
${source_path}/logic/menu/Menu.cpp
${source_path}/logic/menu/Menu.h
${source_path}/logic/menu/PauseMenu.cpp
${source_path}/logic/menu/PauseMenu.h
${source_path}/logic/menu/NewHighscoreMenu.cpp
${source_path}/logic/menu/NewHighscoreMenu.h
${source_path}/logic/menu/items/ControlsItem.cpp
${source_path}/logic/menu/items/ControlsItem.h
${source_path}/logic/menu/items/ControlsListItem.cpp
${source_path}/logic/menu/items/ControlsListItem.h
${source_path}/logic/menu/items/CreditsItem.cpp
${source_path}/logic/menu/items/CreditsItem.h
${source_path}/logic/menu/items/MenuItem.cpp
${source_path}/logic/menu/items/MenuItem.h
${source_path}/logic/menu/items/HighscoreListItem.cpp
${source_path}/logic/menu/items/HighscoreListItem.h
${source_path}/logic/menu/items/MenuButton.cpp
${source_path}/logic/menu/items/MenuButton.h
${source_path}/logic/menu/items/MenuInput.cpp
${source_path}/logic/menu/items/MenuInput.h
${source_path}/logic/menu/items/MenuLogo.cpp
${source_path}/logic/menu/items/MenuLogo.h
${source_path}/logic/menu/items/MenuText.cpp
${source_path}/logic/menu/items/MenuText.h
${source_path}/logic/world/Cave.cpp
${source_path}/logic/world/Cave.h
${source_path}/logic/world/Cuboid.cpp
${source_path}/logic/world/Cuboid.h
${source_path}/logic/world/GameCamera.cpp
${source_path}/logic/world/GameCamera.h
${source_path}/logic/world/GameMechanics.cpp
${source_path}/logic/world/GameMechanics.h
${source_path}/logic/world/Mammut.cpp
${source_path}/logic/world/Mammut.h
${source_path}/logic/world/MammutPhysics.cpp
${source_path}/logic/world/MammutPhysics.h
${source_path}/logic/world/PhysicsObject.cpp
${source_path}/logic/world/PhysicsObject.h
${source_path}/logic/world/PhysicsWorld.cpp
${source_path}/logic/world/PhysicsWorld.h
${source_path}/logic/world/leveldesign/ChunkGenerator.cpp
${source_path}/logic/world/leveldesign/ChunkGenerator.h
${source_path}/logic/world/leveldesign/CuboidChunk.cpp
${source_path}/logic/world/leveldesign/CuboidChunk.h
${source_path}/logic/world/leveldesign/LevelStartChunkGenerator.cpp
${source_path}/logic/world/leveldesign/LevelStartChunkGenerator.h
${source_path}/logic/world/tets/TetGenerator.cpp
${source_path}/logic/world/tets/TetGenerator.h
${source_path}/logic/world/tets/Tet.cpp
${source_path}/logic/world/tets/Tet.h
${source_path}/logic/world/tets/BunchOfTets.cpp
${source_path}/logic/world/tets/BunchOfTets.h
${source_path}/rendering/Canvas.cpp
${source_path}/rendering/Canvas.h
${source_path}/rendering/RawFile.cpp
${source_path}/rendering/RawFile.h
${source_path}/rendering/Renderer.cpp
${source_path}/rendering/Renderer.h
${source_path}/rendering/menu/AbstractBackground.h
${source_path}/rendering/menu/BlankBackground.cpp
${source_path}/rendering/menu/BlankBackground.h
${source_path}/rendering/menu/MenuRenderer.cpp
${source_path}/rendering/menu/MenuRenderer.h
${source_path}/rendering/menu/ScreenshotBackground.cpp
${source_path}/rendering/menu/ScreenshotBackground.h
${source_path}/rendering/text/CharacterDrawable.cpp
${source_path}/rendering/text/CharacterDrawable.h
${source_path}/rendering/text/StringComposer.cpp
${source_path}/rendering/text/StringComposer.h
${source_path}/rendering/text/SDFRenderer.cpp
${source_path}/rendering/text/SDFRenderer.h
${source_path}/rendering/text/SymbolRenderer.cpp
${source_path}/rendering/text/SymbolRenderer.h
${source_path}/rendering/text/TextRenderer.cpp
${source_path}/rendering/text/TextRenderer.h
${source_path}/rendering/world/AbstractPainter.cpp
${source_path}/rendering/world/AbstractPainter.h
${source_path}/rendering/world/BunchOfTetsDrawable.cpp
${source_path}/rendering/world/BunchOfTetsDrawable.h
${source_path}/rendering/world/BunchRenderer.cpp
${source_path}/rendering/world/BunchRenderer.h
${source_path}/rendering/world/CaveDrawable.cpp
${source_path}/rendering/world/CaveDrawable.h
${source_path}/rendering/world/CavePainter.cpp
${source_path}/rendering/world/CavePainter.h
${source_path}/rendering/world/CuboidDrawable.cpp
${source_path}/rendering/world/CuboidDrawable.h
${source_path}/rendering/world/GameWorldRenderer.cpp
${source_path}/rendering/world/GameWorldRenderer.h
${source_path}/rendering/world/HUD.cpp
${source_path}/rendering/world/HUD.h
${source_path}/rendering/world/DrawableInterface.h
${source_path}/rendering/world/Painter.cpp
${source_path}/rendering/world/Painter.h
${source_path}/rendering/world/RenderCamera.cpp
${source_path}/rendering/world/RenderCamera.h
${source_path}/rendering/world/TessCuboidDrawable.cpp
${source_path}/rendering/world/TessCuboidDrawable.h
${source_path}/rendering/world/TetPainter.cpp
${source_path}/rendering/world/TetPainter.h
${source_path}/rendering/world/CuboidRenderer.cpp
${source_path}/rendering/world/CuboidRenderer.h
${source_path}/rendering/world/postprocessing/AbstractPostProcPass.h
${source_path}/rendering/world/postprocessing/MotionBlurPass.cpp
${source_path}/rendering/world/postprocessing/MotionBlurPass.h
${source_path}/rendering/world/postprocessing/SimplePostProcPass.cpp
${source_path}/rendering/world/postprocessing/SimplePostProcPass.hpp
${source_path}/rendering/world/postprocessing/SimplePostProcPass.h
${source_path}/rendering/world/postprocessing/SSAOPass.cpp
${source_path}/rendering/world/postprocessing/SSAOPass.h
${source_path}/sound/SoundManager.cpp
${source_path}/sound/SoundManager.h
${source_path}/sound/Sound.cpp
${source_path}/sound/Sound.h
)
# Group source files
set(MAMMUT_SOURCE_GROUP "Source Files")
source_group_by_path(${source_path} "\\\\.h$|\\\\.hpp$|\\\\.cpp$|\\\\.cxx$|\\\\.c$|\\\\.h$|\\\\.hpp$"
${MAMMUT_SOURCE_GROUP} ${sources})
set(shader_path "${CMAKE_CURRENT_SOURCE_DIR}/data/shaders")
set(shaders
${shader_path}/cuboid.frag
${shader_path}/cuboid.vert
${shader_path}/fxaa.frag
${shader_path}/Fxaa3_11.h
${shader_path}/horizontal_blur.frag
${shader_path}/motionBlur.frag
${shader_path}/motionBlurNM.frag
${shader_path}/motionBlurTM_horizontal.frag
${shader_path}/motionBlurTM_vertical.frag
${shader_path}/screenshot_background.frag
${shader_path}/ssao.frag
${shader_path}/ssao.vert
${shader_path}/string_drawer.frag
${shader_path}/string_drawer.vert
${shader_path}/vertical_blur.frag
)
set(MAMMUT_SHADER_GROUP "Shader Files")
source_group_by_path(${shader_path} "\\\\.vert$|\\\\.frag$"
${MAMMUT_SHADER_GROUP} ${shaders})
# Build library
add_executable(${target} ${sources} ${shaders} ${uihs})
qt5_use_modules(${target} Gui)
target_link_libraries(${target}
${OPENGL_LIBRARIES}
${GLEW_LIBRARY}
${GLOW_LIBRARIES}
${GLOW_UTILS_LIBRARIES}
${BULLET_LIBRARIES}
${FMOD_LIBRARY}
)
set_target_properties(${target}
PROPERTIES
LINKER_LANGUAGE CXX
COMPILE_DEFINITIONS_DEBUG "${DEFAULT_COMPILE_DEFS_DEBUG}"
COMPILE_DEFINITIONS_RELEASE "${DEFAULT_COMPILE_DEFS_RELEASE}"
COMPILE_FLAGS "${DEFAULT_COMPILE_FLAGS}"
LINK_FLAGS_DEBUG "${DEFAULT_LINKER_FLAGS_DEBUG}"
LINK_FLAGS_RELEASE "${DEFAULT_LINKER_FLAGS_RELEASE}"
DEBUG_POSTFIX "d${DEBUG_POSTFIX}")
add_definitions("-DGLM_SWIZZLE")
# Deployment
install(TARGETS ${target}
RUNTIME DESTINATION ${INSTALL_BIN}
LIBRARY DESTINATION ${INSTALL_SHARED}
ARCHIVE DESTINATION ${INSTALL_LIB}
)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${INSTALL_INCLUDE})
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data DESTINATION ${INSTALL_DATA})
# Packaging
# add_subdirectory(packages)