CMakeLists.txt 6.05 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)

4

5
6
7
################################################################################
# Libraries
################################################################################
8

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

Jerry's avatar
Jerry committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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()
31

32
33
34
35
36

#gli library
include_directories(
	${CMAKE_CURRENT_SOURCE_DIR}/lib/gli
)
37
add_subdirectory(lib/gli)
38
39
40
41
42
43
44


#glm library
include_directories(
	${CMAKE_CURRENT_SOURCE_DIR}/lib/glm
)
add_definitions(-DGLM_SWIZZLE)
45
add_subdirectory(lib/glm)
46
47


48
#glew library
Thomas Eppers's avatar
Thomas Eppers committed
49
50
51
if (WIN32)
	add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif ()
52
53
include_directories(
	${CMAKE_CURRENT_SOURCE_DIR}/lib/glew/include
54
)
55
set(glew_SRC
56
57
58
59
60
	${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)
61
add_library(glew_static ${glew_SRC})
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
#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})
105

106
107
108
109
110
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
111
)
112
add_library(DebugUtils ${debugutils_SRC})
Jerry's avatar
Jerry committed
113
114


115
116
117
118
#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
119
)
120
add_library(nanovg ${nanovg_SRC})
Jerry's avatar
Jerry committed
121
122


123
124
125
################################################################################
# Project settings
################################################################################
Jerry's avatar
Jerry committed
126

127
128
#set compiler options
if (${CMAKE_CXX_COMPILER} MATCHES "clang")
129
	set(CMAKE_CXX_FLAGS "${CMAKE_FXX_FLAGS} -stdlib=libc++")
130
131
132
133
134
135
136
137
138
139
140
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
141

142
#include directory of project
143
144
include_directories(
	${CMAKE_CURRENT_SOURCE_DIR}/include
145
146
)

147
148
149
150
151
152
153
154
155
156
157
#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
)
158

159
#libraries to link
160
set(LINKED_LIBRARIES
161
162
163
164
165
166
	glew_static
	nanovg
	DebugUtils
	DetourCrowd
	Detour
	Recast
Jerry's avatar
Jerry committed
167
168
		SDL2main
		SDL2
169
170
171
	SDL2_mixer
)

Jerry's avatar
Jerry committed
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
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()


189
#build executable and then link to the libraries
190
add_executable(Game ${project_SRC} ${project_HDR} ${project_INL})
191
target_link_libraries(Game ${LINKED_LIBRARIES})
192

193
#copy assets to the executable destination
194
file(COPY assets DESTINATION .)