CMakeLists.txt 6.47 KB
Newer Older
Thomas Eppers's avatar
Thomas Eppers committed
1
cmake_minimum_required(VERSION 2.8)
Michael Ochmann's avatar
Michael Ochmann committed
2
3
project(gdw_ss15_cpp)

Georg Schäfer's avatar
Georg Schäfer committed
4
cmake_policy(SET CMP0072 NEW)
5

6
7
8
################################################################################
# Libraries
################################################################################
9

Michael Ochmann's avatar
Michael Ochmann committed
10
find_package(OpenGL)
11

Jerry's avatar
Jerry committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
if(UNIX)
	include(FindPkgConfig)
	PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2)
	PKG_SEARCH_MODULE(SDL2MIXER REQUIRED SDL2_mixer)
	include_directories(
		${SDL2_INCLUDE_DIRS}
		${SDL2_mixer_INCLUDE_DIRS}
	)
elseif(WIN32)
	include_directories(
		${CMAKE_CURRENT_SOURCE_DIR}/lib/sdl2/include
		${CMAKE_CURRENT_SOURCE_DIR}/lib/sdl2_mixer/x86_64-w64-mingw32/include/SDL2
	)
	link_directories(
		${CMAKE_CURRENT_SOURCE_DIR}/lib/sdl2/x86_64-w64-mingw32/lib
		${CMAKE_CURRENT_SOURCE_DIR}/lib/sdl2_mixer/x86_64-w64-mingw32/lib
	)
	file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/lib/sdl2/x86_64-w64-mingw32/bin/SDL2.dll DESTINATION .)
	file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/lib/sdl2_mixer/x86_64-w64-mingw32/bin/ DESTINATION . FILES_MATCHING PATTERN *.dll)
endif()
32

33

Georg Schäfer's avatar
Georg Schäfer committed
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
add_library(glm INTERFACE)
target_include_directories(glm INTERFACE
		${CMAKE_CURRENT_SOURCE_DIR}/lib/glm)
target_compile_options(glm INTERFACE
		-Wno-all
		-Wno-extra
		-Wno-pedantic
		-Wno-error)
target_compile_definitions(glm INTERFACE
	GLM_ENABLE_EXPERIMENTAL
	GLM_SWIZZLE)
add_library(gli INTERFACE)
target_include_directories(gli INTERFACE
		${CMAKE_CURRENT_SOURCE_DIR}/lib/gli)
target_compile_options(gli INTERFACE
		-Wno-all
		-Wno-extra
		-Wno-pedantic
		-Wno-error)
53
54


55
#glew library
Thomas Eppers's avatar
Thomas Eppers committed
56
57
58
if (WIN32)
	add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif ()
59
60
include_directories(
	${CMAKE_CURRENT_SOURCE_DIR}/lib/glew/include
61
)
62
set(glew_SRC
63
64
65
66
67
	${CMAKE_CURRENT_SOURCE_DIR}/lib/glew/src/glew.c
	${CMAKE_CURRENT_SOURCE_DIR}/lib/glew/src/glewinfo.c
	${CMAKE_CURRENT_SOURCE_DIR}/lib/glew/src/visualinfo.c
)
add_definitions(-DGLEW_STATIC)
68
add_library(glew_static ${glew_SRC})
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
#recastNavigation library
include_directories(
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Recast/Include
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Detour/Include
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DetourCrowd/Include
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DetourTileCache/Include
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DebugUtils/Include
)
set(recast_SRC
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Recast/Source/Recast.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Recast/Source/RecastArea.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Recast/Source/RecastAlloc.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Recast/Source/RecastContour.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Recast/Source/RecastFilter.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Recast/Source/RecastLayers.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Recast/Source/RecastMesh.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Recast/Source/RecastMeshDetail.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Recast/Source/RecastRasterization.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Recast/Source/RecastRegion.cpp
)
add_library(Recast ${recast_SRC})

set(detour_SRC
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Detour/Source/DetourAlloc.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Detour/Source/DetourCommon.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Detour/Source/DetourNavMesh.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Detour/Source/DetourNavMeshBuilder.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Detour/Source/DetourNode.cpp
)
add_library(Detour ${detour_SRC})

set(detourcrowd_SRC
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DetourCrowd/Source/DetourPathCorridor.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DetourCrowd/Source/DetourLocalBoundary.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DetourCrowd/Source/DetourObstacleAvoidance.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DetourCrowd/Source/DetourPathQueue.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DetourCrowd/Source/DetourCrowd.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DetourCrowd/Source/DetourProximityGrid.cpp
)
add_library(DetourCrowd ${detourcrowd_SRC})
112

113
114
115
116
117
set(debugutils_SRC
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DebugUtils/Source/DebugDraw.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DebugUtils/Source/DetourDebugDraw.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DebugUtils/Source/RecastDebugDraw.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DebugUtils/Source/RecastDump.cpp
Jerry's avatar
Jerry committed
118
)
119
add_library(DebugUtils ${debugutils_SRC})
Jerry's avatar
Jerry committed
120
121


122
123
124
125
#nanovg library
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib/nanovg/src)
set(nanovg_SRC
	${CMAKE_CURRENT_SOURCE_DIR}/lib/nanovg/src/nanovg.c
Jerry's avatar
Jerry committed
126
)
127
add_library(nanovg ${nanovg_SRC})
Jerry's avatar
Jerry committed
128
129


130
131
132
################################################################################
# Project settings
################################################################################
Jerry's avatar
Jerry committed
133

134
135
#set compiler options
if (${CMAKE_CXX_COMPILER} MATCHES "clang")
136
	set(CMAKE_CXX_FLAGS "${CMAKE_FXX_FLAGS} -stdlib=libc++")
137
138
139
140
141
142
143
144
145
146
147
endif ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -Wall -Wextra")

#define symbols for debug build
if (CMAKE_BUILD_TYPE STREQUAL Debug)
	add_definitions(-DDEBUG)
	if (NOT MSVC)
		add_definitions(-DSTACKTRACE)
	endif ()
endif ()
Jerry's avatar
Jerry committed
148

149
#include directory of project
150
151
include_directories(
	${CMAKE_CURRENT_SOURCE_DIR}/include
152
153
)

154
155
156
157
158
159
160
161
162
163
164
#project files to compile
file(GLOB_RECURSE project_SRC
	${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp
)
file(GLOB_RECURSE project_HDR
	${CMAKE_CURRENT_SOURCE_DIR}/include/*.h
	${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp
)
file(GLOB_RECURSE project_INL
	${CMAKE_CURRENT_SOURCE_DIR}/*.inl
)
165

166
#libraries to link
167
set(LINKED_LIBRARIES
168
169
170
171
172
173
	glew_static
	nanovg
	DebugUtils
	DetourCrowd
	Detour
	Recast
Jerry's avatar
Jerry committed
174
175
		SDL2main
		SDL2
176
	SDL2_mixer
Georg Schäfer's avatar
Georg Schäfer committed
177
178
	glm
	gli
179
180
)

Jerry's avatar
Jerry committed
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
if(UNIX)
	set( LINKED_LIBRARIES
			${LINKED_LIBRARIES}
			GL
			c++
			c++abi)
elseif(WIN32)
	set( LINKED_LIBRARIES
		imagehlp
		mingw32
		${LINKED_LIBRARIES}
		opengl32
		-static-libgcc
		-static-libstdc++)
endif()


198
#build executable and then link to the libraries
199
add_executable(Game ${project_SRC} ${project_HDR} ${project_INL})
200
target_link_libraries(Game ${LINKED_LIBRARIES})
201

202
#copy assets to the executable destination
Georg Schäfer's avatar
Georg Schäfer committed
203
204
205
206
207
add_custom_target(assets
	${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/assets ${CMAKE_CURRENT_BINARY_DIR}
	COMMENT "Copying assets")
add_dependencies(Game
	assets)