forked from SFTtech/openage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
200 lines (154 loc) · 5.11 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
# Copyright 2013-2017 the openage authors. See copying.md for legal info.
cmake_minimum_required(VERSION 3.8.0)
# required for CMAKE_CXX_STANDARD for C++17
# main build configuration file
# text art: figlet -f rounded "[SFT] openage" | sed -e 's/\\/\\\\/g'
message("
___ ______ _______ _______ ___
| _)/ _____|_______|_______|_ |
| | ( (____ _____ _ | | ___ ____ _____ ____ _____ ____ _____
| | \\____ \\| ___) | | | | / _ \\| _ \\| ___ | _ \\(____ |/ _ | ___ |
| |_ _____) ) | | | _| | | |_| | |_| | ____| | | / ___ ( (_| | ____|
|___|______/|_| |_| (___| \\___/| __/|_____)_| |_\\_____|\\___ |_____)
|_| (_____|
Welcome to the SFT technologies computer-aided openage build system!
You have chosen, or been chosen, to attempt the daring task of building openage.
If you have installed all the dependencies that are conveniently listed in
[doc/building.md], this _might_ just work!
If it doesn't, consider reporting the issue: https://github.com/SFTtech/openage
Or ask for help:
* Matrix: #sfttech:matrix.org
* IRC: #sfttech on freenode.net
")
project(openage CXX)
# C++ standard requirement
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Python and Cython requirements
set(PYTHON_MIN_VERSION 3.4)
set(CYTHON_MIN_VERSION 0.25)
# CMake policies
foreach(pol CMP0071 # enable automoc for generated files
)
if (POLICY ${pol})
cmake_policy(SET ${pol} NEW)
endif()
endforeach()
# Ensure CMAKE_BUILD_TYPE is set correctly.
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()
string(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" BUILD_TYPE_CXX_FLAGS)
# options: keep up to date with those in ./configure!
if(NOT DEFINED WANT_BACKTRACE)
set(WANT_BACKTRACE if_available)
endif()
if(NOT DEFINED WANT_INOTIFY)
set(WANT_INOTIFY if_available)
endif()
if(NOT DEFINED WANT_GPERFTOOLS_PROFILER)
set(WANT_GPERFTOOLS_PROFILER if_available)
endif()
if(NOT DEFINED WANT_GPERFTOOLS_TCMALLOC)
set(WANT_GPERFTOOLS_TCMALLOC false)
endif()
# static content filesystem locations
if(NOT DEFINED GLOBAL_ASSET_DIR)
set(ASSET_DIR "share/openage")
if(MSVC)
set(GLOBAL_ASSET_DIR "${ASSET_DIR}")
else()
set(GLOBAL_ASSET_DIR "${CMAKE_INSTALL_PREFIX}/${ASSET_DIR}")
endif()
endif()
if(NOT DEFINED GLOBAL_CONFIG_DIR)
set(CONFIG_DIR "etc/openage")
if(MSVC)
set(GLOBAL_CONFIG_DIR "${CONFIG_DIR}")
else()
set(GLOBAL_CONFIG_DIR "/${CONFIG_DIR}")
endif()
endif()
# build the project with ccache
# distros can also do this but they don't use this mechanism
option(ENABLE_CCACHE "prefix each compile command with ccache")
if(ENABLE_CCACHE)
find_program(CCACHE_FOUND "ccache")
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
else()
message(FATAL_ERROR "ccache not found, but you requested it")
endif(CCACHE_FOUND)
endif()
# clang tidy static analysis
option(
ENABLE_CLANG_TIDY
"activate clang tidy messages"
OFF
)
if(ENABLE_CLANG_TIDY)
set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-checks=-*,readability-*")
endif()
# option processing is now done.
# add search paths to helper modules
set(BUILDSYSTEM_DIR "${CMAKE_SOURCE_DIR}/buildsystem")
set(CMAKE_MODULE_PATH "${BUILDSYSTEM_DIR}" "${BUILDSYSTEM_DIR}/modules/")
# load helper modules
include(GNUInstallDirs)
include(CheckInSourceBuild)
include(HandleCXXOptions)
include(CheckCompilerFeatures)
include(CMakeParseArguments)
include(HandlePythonOptions)
include(CheckRuntimeDependencies)
include(DetectProjectVersion)
include(DependencyFetch)
# include build configuration modules
include(CTest)
# initialize language support
include(codegen)
include(cpp)
include(doxygen)
include(options)
include(python)
include(util)
# now that all modules and settings are loaded,
# apply those to the project:
# create documentation
doxygen_configure(libopenage/ openage/ doc/ README.md)
# static content
add_subdirectory(assets/)
add_subdirectory(dist/)
add_subdirectory(cfg/)
# C++ content
add_subdirectory(libopenage/)
# Python content (uses the C++ library)
set(PYEXT_LINK_LIBRARY libopenage)
if(MSVC)
set(FORCE_INCLUDE_CXXFLAG "/FI")
else()
set(FORCE_INCLUDE_CXXFLAG "-include ")
endif()
set(PYEXT_CXXFLAGS "${PYEXT_CXXFLAGS} ${FORCE_INCLUDE_CXXFLAG}\"${CMAKE_SOURCE_DIR}/libopenage/pyinterface/hacks.h\"")
add_cython_modules(EMBED NOINSTALL run.py)
add_py_modules(BININSTALL run.py AS openage)
add_subdirectory(openage/)
python_finalize()
# Ensure that packaging is always the last step.
add_subdirectory(packaging)
message("")
print_config_options()
# show build configuration overview
message("${PROJECT_NAME} ${PROJECT_VERSION}
compiler | ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}
build type | ${CMAKE_BUILD_TYPE}
cxxflags | ${CMAKE_CXX_FLAGS}
build type flags | ${${BUILD_TYPE_CXX_FLAGS}}
build dir | ${CMAKE_BINARY_DIR}
install prefix | ${CMAKE_INSTALL_PREFIX}
py install prefix | ${CMAKE_PY_INSTALL_PREFIX}
")
# don't print 'Built target ...' messages
# upstream since cmake v3.4.0-rc1 (by commit 1d3984780df8)
set_property(GLOBAL PROPERTY TARGET_MESSAGES OFF)