/
CMakeLists.txt
151 lines (135 loc) · 5.61 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
# 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 2.8)
project(Unvanquished C CXX)
# 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/libRocket"
"src/utils/cbse")
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_CGAME AND (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)
find_package(Lua REQUIRED)
endif()
include(${CMAKE_CURRENT_SOURCE_DIR}/libRocket.cmake)
include_directories(${FREETYPE_INCLUDE_DIRS} ${LUA_INCLUDE_DIR})
set_target_properties(ROCKET_LIB PROPERTIES FOLDER "libs")
include_directories(${ROCKET_INCLUDE_DIRS})
endif()
# Warning options
# keep
try_flag(WARNINGS "/wd4068")
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")
try_flag(WARNINGS "-Wno-error=sign-promo")
if (NOT BE_VERBOSE)
try_flag(WARNINGS "-Wno-error=strict-overflow")
endif()
# remove
try_flag(WARNINGS "-Wno-error=maybe-uninitialized")
try_flag(WARNINGS "-W${WARNMODE}missing-field-initializers")
try_flag(WARNINGS "-W${WARNMODE}sign-compare")
try_flag(WARNINGS "-Wno-error=switch")
try_flag(WARNINGS "-Wno-error=unused-but-set-variable")
try_flag(WARNINGS "-Wno-error=unused-function")
try_flag(WARNINGS "-W${WARNMODE}unused-parameter")
try_flag(WARNINGS "-Wno-error=unused-private-field")
if (BUILD_SGAME)
include(DaemonCBSE)
CBSE("sgame"
"${GAMELOGIC_DIR}/sgame/entities.yaml"
"${GAMELOGIC_DIR}/sgame/")
GAMEMODULE(NAME sgame
DEFINITIONS
BUILD_SGAME
FLAGS
${WARNINGS}
FILES
${SGAMELIST}
${sgame_GENERATED_CBSE}
)
endif()
if (BUILD_CGAME)
GAMEMODULE(NAME cgame
DEFINITIONS
BUILD_CGAME
ROCKET_STATIC_LIB
FLAGS
${WARNINGS}
FILES
${CGAMELIST}
LIBS
ROCKET_LIB
${FREETYPE_LIBRARIES}
${LUA_LIBRARY}
)
endif()