forked from Unvanquished/Unvanquished
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
210 lines (183 loc) · 7.85 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
# Unvanquished BSD Source Code
# Copyright (c) 2013-2014, Unvanquished Developers
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the <organization> nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cmake_minimum_required(VERSION 3.12)
project(Unvanquished C CXX)
# On Mac, default to x86_64 unless user requests something else
if (NOT CMAKE_OSX_ARCHITECTURES)
set(CMAKE_OSX_ARCHITECTURES x86_64)
endif()
# When we build in the source dir, the daemon executable cannot be create
# as there is already a daemon directory, so we disallow building in the
# source dir.
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "Building in the source directory is not supported, try building in a 'build' directory. You may have to delete the CMakeCache.txt file and CMakeFiles directory that are next to the CMakeLists.txt.")
endif()
set(SUBMODULE_LIST
"libs/RmlUi"
)
set(DAEMON_DIR_STRING "Path to the Daemon Engine source.")
if(NOT DAEMON_DIR)
set(DAEMON_DIR "${CMAKE_CURRENT_SOURCE_DIR}/daemon" CACHE STRING "${DAEMON_DIR_STRING}")
LIST(APPEND SUBMODULE_LIST "daemon")
else()
set(DAEMON_DIR "${DAEMON_DIR}" CACHE STRING "${DAEMON_DIR_STRING}")
endif()
foreach(SUBMODULE_PATH ${SUBMODULE_LIST})
# Check if we need to initialize submodule
file(GLOB DENG_RESULT "${CMAKE_CURRENT_SOURCE_DIR}/${SUBMODULE_PATH}")
list(LENGTH DENG_RESULT DENG_RES_LEN)
if(DENG_RES_LEN EQUAL 0)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
find_package(Git REQUIRED)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive -- "${SUBMODULE_PATH}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif()
endif()
endif()
endforeach()
set(Daemon_OUT ${CMAKE_CURRENT_BINARY_DIR})
add_subdirectory("${DAEMON_DIR}" daemon_build)
include(DaemonGame)
set(LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libs)
include_directories(${LIB_DIR})
set(GAMELOGIC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
include_directories(${GAMELOGIC_DIR})
include(src.cmake)
option(BUILD_CGAME "Build client-side gamelogic" 1)
option(BUILD_SGAME "Build server-side gamelogic" 1)
if (BUILD_GAME_NATIVE_DLL OR BUILD_GAME_NATIVE_EXE OR NACL)
if (NACL)
set(FREETYPE_LIBRARY ${DEPS_DIR}/pnacl_deps/lib/libfreetype.a)
set(FREETYPE_LIBRARIES ${FREETYPE_LIBRARY} ${DEPS_DIR}/pnacl_deps/lib/libpng16.a)
set(FREETYPE_INCLUDE_DIRS ${DEPS_DIR}/pnacl_deps/include/freetype2)
set(LUA_INCLUDE_DIR ${DEPS_DIR}/pnacl_deps/include)
set(LUA_LIBRARY ${DEPS_DIR}/pnacl_deps/lib/liblua.a)
else()
find_package(Freetype REQUIRED)
if (APPLE OR WIN32)
find_package(ZLIB REQUIRED)
set(FREETYPE_LIBRARIES ${FREETYPE_LIBRARIES} ${ZLIB_LIBRARIES})
endif()
find_package(Lua REQUIRED)
endif()
include(${CMAKE_CURRENT_SOURCE_DIR}/rmlui.cmake)
include_directories(${FREETYPE_INCLUDE_DIRS} ${LUA_INCLUDE_DIR})
set_target_properties(RMLUI_LIB PROPERTIES FOLDER "libs")
include_directories(${RMLUI_INCLUDE_DIRS})
endif()
if (BUILD_SGAME OR BUILD_CGAME)
# Fastlz
add_library(srclibs-fastlz EXCLUDE_FROM_ALL ${FASTLZLIST})
set_target_properties(srclibs-fastlz PROPERTIES POSITION_INDEPENDENT_CODE 1 FOLDER "libs")
# Detour
add_library(srclibs-detour EXCLUDE_FROM_ALL ${DETOURLIST})
set_target_properties(srclibs-detour PROPERTIES POSITION_INDEPENDENT_CODE 1 FOLDER "libs")
include_directories(${LIB_DIR}/recastnavigation/Detour/Include
${LIB_DIR}/recastnavigation/DetourTileCache/Include
${LIB_DIR}/recastnavigation/DebugUtils/Include
${LIB_DIR}/recastnavigation/DetourCrowd/Include)
# Recast
set(RC_MAX_LAYERS 63 CACHE STRING "Must be 255 or smaller.")
set(RC_MAX_NEIS 16 CACHE STRING "")
if (RC_MAX_LAYERS GREATER 255)
message(FATAL_ERROR "RC_MAX_LAYERS must be 255 or smaller")
endif()
add_definitions(-DRC_MAX_LAYERS_DEF=${RC_MAX_LAYERS})
add_definitions(-DRC_MAX_NEIS_DEF=${RC_MAX_NEIS})
add_library(srclibs-recast EXCLUDE_FROM_ALL ${RECASTLIST})
set_target_properties(srclibs-recast PROPERTIES POSITION_INDEPENDENT_CODE 1 FOLDER "libs")
include_directories(
${LIB_DIR}/recastnavigation/Recast/Include
${LIB_DIR}/recastnavigation/RecastDemo/Include)
# GLM
include_directories(${LIB_DIR}/glm)
endif()
add_definitions( -DGLM_FORCE_EXPLICIT_CTOR )
add_library(srclibs-tinygettext EXCLUDE_FROM_ALL ${TINYGETTEXTLIST})
set_target_properties(srclibs-tinygettext PROPERTIES POSITION_INDEPENDENT_CODE 1 FOLDER "libs")
target_include_directories(srclibs-tinygettext PUBLIC ${LIB_DIR}/tinygettext/include)
target_compile_definitions(srclibs-tinygettext PUBLIC TINYGETTEXT_UTF8_ONLY)
# Warning options for Unvanquished source code
# keep
try_flag(WARNINGS "-Wno-pragmas")
try_flag(WARNINGS "-Wno-unknown-pragmas")
try_flag(WARNINGS "-W${WARNMODE}old-style-cast")
try_flag(WARNINGS "-Woverloaded-virtual")
try_flag(WARNINGS "-Wstrict-null-sentinel")
# Since OSX uses newer compilers, they complain about some of header only libs.
# So, ignore deprecation warnings on OSX.
if (APPLE)
# Do not error for GLM vsprintf deprecation warnings.
try_flag(WARNINGS "-Wno-error=deprecated-declarations")
endif()
# remove
try_flag(WARNINGS "-Wno-maybe-uninitialized")
try_flag(WARNINGS "/wd4127") # conditional expression is constant
try_flag(WARNINGS "/wd4458") # declaration of 'XXX' hides class member
try_flag(WARNINGS "/wd4459") # declaration of 'XXX' hides global declaration
try_flag(WARNINGS "/wd4701") # potentially uninitialized local variable 'XXX' used
try_flag(WARNINGS "/wd26812") # The enum 'XXX' is unscoped. Prefer 'enum class' over 'enum'
if (BUILD_SGAME)
include(tools/cbse/CBSE.cmake)
CBSE("sgame"
"${GAMELOGIC_DIR}/sgame/entities.yaml"
"${GAMELOGIC_DIR}/sgame/")
GAMEMODULE(NAME sgame
DEFINITIONS
BUILD_SGAME
FLAGS
${WARNINGS}
FILES
${SGAMELIST}
${sgame_GENERATED_CBSE}
LIBS
${LUA_LIBRARY}
srclibs-detour
srclibs-recast
srclibs-fastlz
)
endif()
if (BUILD_CGAME)
GAMEMODULE(NAME cgame
DEFINITIONS
BUILD_CGAME
RMLUI_STATIC_LIB
FLAGS
${WARNINGS}
FILES
${CGAMELIST}
LIBS
RMLUI_LIB
${FREETYPE_LIBRARIES}
${LUA_LIBRARY}
srclibs-tinygettext
srclibs-detour
srclibs-recast
srclibs-fastlz
)
endif()