forked from odamex/odamex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
215 lines (185 loc) · 7.35 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
211
212
213
214
215
# use unquoted #defines
if(COMMAND cmake_policy)
cmake_policy(SET CMP0005 NEW)
endif(COMMAND cmake_policy)
include(CMakeDependentOption)
# CMAKE_INSTALL_BINDIR and CMAKE_INSTALL_DATADIR will be changed if GNUInstallDirs is availible
set(CMAKE_INSTALL_BINDIR "bin")
set(CMAKE_INSTALL_DATADIR "share")
include(GNUInstallDirs OPTIONAL)
add_definitions(-DINSTALL_BINDIR="${CMAKE_INSTALL_BINDIR}")
add_definitions(-DINSTALL_DATADIR="${CMAKE_INSTALL_DATADIR}")
# options
option(BUILD_CLIENT "Build client target" 1)
option(BUILD_SERVER "Build server target" 1)
option(BUILD_MASTER "Build master server target" 1)
option(BUILD_ODALAUNCH "Build odalaunch target" 1)
cmake_dependent_option( ENABLE_PORTMIDI "Enable portmidi support" 1 BUILD_CLIENT 0 )
cmake_dependent_option( USE_MINIUPNP "Build with UPnP support" 1 BUILD_SERVER 0 )
project(Odamex)
cmake_minimum_required(VERSION 2.8)
set(PROJECT_VERSION 0.8.1)
set(PROJECT_COPYRIGHT "2006-2019")
# identify the target CPU
# adapted from the FindJNI.cmake module included with the CMake distribution
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(target_arch "amd64")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^i[3-9]86$")
set(target_arch "i386")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^alpha")
set(target_arch "alpha")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
set(target_arch "arm")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64")
set(target_arch "ppc64")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)")
set(target_arch "ppc")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^sparc")
# Both flavors can run on the same processor
set(target_arch "${CMAKE_SYSTEM_PROCESSOR}" "sparc" "sparcv9")
else()
set(target_arch "${CMAKE_SYSTEM_PROCESSOR}")
endif()
list(REMOVE_DUPLICATES target_arch)
message("Using target architecture " ${target_arch})
# Default build type
if(NOT MSVC)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif()
endif()
# Global compile options as shown in a GUI.
if(NOT MSVC)
set(USE_STATIC_STDLIB "No" CACHE STRING
"Statically link against the C and C++ Standard Library.")
set_property(CACHE USE_STATIC_STDLIB PROPERTY STRINGS Yes No)
set(USE_SANITIZE_ADDRESS "No" CACHE STRING
"Turn on Address Sanitizer in Debug builds, requires GCC >= 4.8 or Clang >= 3.1")
set_property(CACHE USE_SANITIZE_ADDRESS PROPERTY STRINGS Yes No)
endif()
# Global compile options. Useful defines for any Odamex project.
macro(global_compile_options)
if(NOT MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
if(USE_STATIC_STDLIB)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
endif()
if(USE_SANITIZE_ADDRESS)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls")
endif()
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
add_definitions(-DODAMEX_DEBUG)
endif()
endif()
endmacro(global_compile_options)
if(${CMAKE_SYSTEM_NAME} MATCHES SunOS )
set(SOLARIS 1)
endif()
# Platform definitions
# [AM] TODO: Eliminate redundant defines
macro(define_platform)
if(APPLE)
add_definitions(-DOSX -DUNIX )
elseif(SOLARIS)
add_definitions(-DSOLARIS -DUNIX -DBSD_COMP -gstabs+)
elseif(UNIX)
add_definitions(-DUNIX)
find_package(X11)
if(X11_FOUND)
add_definitions(-DX11)
INCLUDE_DIRECTORIES ( ${X11_INCLUDE_DIR} )
LINK_LIBRARIES ( ${X11_LIBRARIES} )
MESSAGE ( STATUS " X11_INCLUDE_DIR: " ${X11_INCLUDE_DIR} )
MESSAGE ( STATUS " X11_LIBRARIES: " ${X11_LIBRARIES} )
endif()
endif()
endmacro(define_platform)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
# git describe
include(GetGitRevisionDescription)
git_describe(GIT_DESCRIBE --tags --always)
# MiniUPnPc
if (USE_MINIUPNP)
set(UPNPC_BUILD_STATIC ON CACHE INTERNAL "" FORCE)
set(UPNPC_BUILD_SHARED OFF CACHE INTERNAL "" FORCE)
set(UPNPC_BUILD_TESTS OFF CACHE INTERNAL "" FORCE)
set(UPNPC_INSTALL OFF CACHE INTERNAL "" FORCE)
mark_as_advanced(FORCE UPNPC_INSTALL)
add_subdirectory(libraries/libminiupnpc)
endif()
# Subdirectories for Odamex projects
if(BUILD_CLIENT)
add_subdirectory(client)
endif()
if(BUILD_SERVER)
add_subdirectory(server)
endif()
if(BUILD_MASTER)
add_subdirectory(master)
endif()
if(BUILD_ODALAUNCH)
add_subdirectory(odalaunch)
endif()
if(NOT BUILD_CLIENT AND NOT BUILD_SERVER AND NOT BUILD_MASTER)
message(FATAL_ERROR "No target chosen, doing nothing.")
endif()
# Disable the ag-odalaunch target completely: -DNO_AG-ODALAUNCH_TARGET
# This is only really useful when setting up a universal build.
if(NOT NO_AG-ODALAUNCH_TARGET)
add_subdirectory(ag-odalaunch)
endif()
# Packaging options.
# TODO: Integrate OSX stuff into here.
if(NOT APPLE)
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_INSTALL_DIRECTORY Odamex)
set(CPACK_RESOURCE_FILE_LICENSE ${PROJECT_SOURCE_DIR}/LICENSE)
set(CPACK_COMPONENTS_ALL client server odalaunch common)
set(CPACK_COMPONENT_CLIENT_DEPENDS common)
set(CPACK_COMPONENT_CLIENT_DISPLAY_NAME "Odamex")
set(CPACK_COMPONENT_SERVER_DEPENDS common)
set(CPACK_COMPONENT_SERVER_DISPLAY_NAME "Odamex Dedicated Server")
set(CPACK_COMPONENT_ODALAUNCH_DEPENDS client)
set(CPACK_COMPONENT_ODALAUNCH_DISPLAY_NAME "Odalaunch Odamex Server Browser and Launcher")
set(CPACK_COMPONENT_COMMON_DISPLAY_NAME "Support files")
# TODO: If deutex is available, use that to build the wad.
file(GLOB CONFIG_SAMPLES config-samples/*.cfg)
if(WIN32)
install(FILES odamex.wad LICENSE README
DESTINATION .
COMPONENT common)
install(FILES ${CONFIG_SAMPLES}
DESTINATION config-samples
COMPONENT common)
# Windows ZIP packages are "tarbombs" by default.
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
else()
install(FILES odamex.wad LICENSE README
DESTINATION ${CMAKE_INSTALL_DATADIR}/odamex
COMPONENT common)
install(FILES ${CONFIG_SAMPLES}
DESTINATION ${CMAKE_INSTALL_DATADIR}/odamex/config-samples
COMPONENT common)
option(ODAMEX_COMPONENT_PACKAGES "Create several rpm/deb packages for repository maintainers." OFF)
if(ODAMEX_COMPONENT_PACKAGES)
set(CPACK_RPM_COMPONENT_INSTALL YES)
# TODO: RPM Dependencies
set(CPACK_DEB_COMPONENT_INSTALL YES)
# TODO: DEB Dependencies
else()
# TODO: RPM Dependencies
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6, libstdc++6, libsdl1.2debian, libsdl-mixer1.2, libwxbase2.8-0, libwxgtk2.8-0")
set(CPACK_DEBIAN_PACKAGE_SUGGESTS "boom-wad | doom-wad, libportmidi0")
endif()
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A free, cross-platform modification of the Doom engine that allows players to easily join servers dedicated to playing Doom online.")
set(CPACK_PACKAGE_VENDOR "Odamex Development Team")
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
set(CPACK_RPM_PACKAGE_LICENSE "GPLv2+")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://odamex.net")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Alex Mayfield <[email protected]>")
set(CPACK_DEBIAN_PACKAGE_SECTION Games)
endif()
endif()
include(CPack)