-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
executable file
·234 lines (203 loc) · 9.42 KB
/
Copy pathCMakeLists.txt
File metadata and controls
executable file
·234 lines (203 loc) · 9.42 KB
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# SPDX-License-Identifier: GPL-3.0-or-later
#
# MaNGOS is a full featured server for World of Warcraft, supporting
# the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
#
# Copyright (C) 2005-2026 MaNGOS <https://www.getmangos.eu>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
project(MaNGOS VERSION 0.22.0 LANGUAGES C CXX)
# Build artefacts never land in the source tree. This is a test, not hygiene:
# sources here still carry relative includes like "../../dep/foo.h", and an
# in-source build tree can make those resolve by accident.
if(CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR)
message(FATAL_ERROR
"In-source builds are not supported. Configure from a separate build "
"directory, e.g. cmake -S . -B ../build")
endif()
cmake_policy(SET CMP0028 NEW)
cmake_policy(SET CMP0054 NEW)
cmake_policy(SET CMP0042 NEW)
cmake_policy(SET CMP0048 NEW)
cmake_policy(SET CMP0063 NEW)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set_property(GLOBAL
PROPERTY USE_FOLDERS ON
)
# Always export compile_commands.json for tooling
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
#==================================================================================
# Define available cmake options below
option(BUILD_MANGOSD "Build the main server" ON)
option(BUILD_REALMD "Build the login server" ON)
option(BUILD_TOOLS "Build the client-data extractor" ON)
option(SCRIPT_LIB_ELUNA "Compile with support for Eluna scripts" ON)
option(SCRIPT_LIB_SD3 "Compile with support for ScriptDev3 scripts" ON)
option(PLAYERBOTS "Enable Player Bots" OFF)
option(SOAP "Enable remote access via SOAP" OFF)
option(PCH "Enable precompiled headers" ON)
option(WITH_IO_URING "Use the io_uring network backend (Linux, needs liburing)" OFF)
option(WITH_TESTS "Build the unit tests" OFF)
option(WITH_NET_TESTS "Build the socket tests (slow; never in CI)" OFF)
option(DEBUG "Enable debug build (only on non IDEs)" OFF)
option(WITHOUT_GIT "Disable Git revision detection" OFF)
#==================================================================================
message("")
message(
"This script builds the MaNGOS server.
Options that can be used in order to configure the process:
General:
CMAKE_INSTALL_PREFIX Path where the server should be installed to
BUILD_MANGOSD Build the main server
BUILD_REALMD Build the login server
BUILD_TOOLS Build the client-data extractor
SOAP Enable remote access via SOAP
PCH Enable use of precompiled headers
WITH_IO_URING Use the io_uring network backend instead of epoll (Linux only,
requires liburing headers; falls back to epoll if absent)
WITH_TESTS Build the unit tests (target: mangos_tests)
WITH_NET_TESTS Build the socket tests as well. Disjoint from WITH_TESTS,
off by default, and deliberately not run in CI: they bind
real sockets and dominate the suite's wall-clock time.
DEBUG Debug build, only for systems without IDE (Linux, *BSD)
Scripting engines:
SCRIPT_LIB_ELUNA Compile with support for Eluna scripts
SCRIPT_LIB_SD3 Compile with support for ScriptDev3 scripts
Modules:
PLAYERBOTS Enable Player Bots
To set an option simply type -D<OPTION>=<VALUE> after 'cmake <srcs>'.
Also, you can specify the generator with -G. See 'cmake --help' for more details
For example: cmake .. -DCMAKE_INSTALL_PREFIX=/opt/mangos -DSCRIPT_LIB_SD3=0"
)
message("")
#==================================================================================#
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "Default install directory" FORCE)
endif()
if(NOT CMAKE_CONFIGURATION_TYPES)
if(DEBUG)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE)
else()
set(CMAKE_BUILD_TYPE Release CACHE STRING "" FORCE)
endif()
endif()
if(UNIX)
set(BIN_DIR ${CMAKE_INSTALL_PREFIX}/bin)
if (NOT CONF_INSTALL_DIR)
set(CONF_INSTALL_DIR ../etc)
endif()
else()
set(BIN_DIR ${CMAKE_INSTALL_PREFIX})
if (NOT CONF_INSTALL_DIR)
set(CONF_INSTALL_DIR .)
endif()
endif()
if(NOT WITHOUT_GIT)
find_package(Git QUIET)
endif()
find_package(Threads REQUIRED)
find_package(MySQL REQUIRED)
find_package(ZLIB QUIET)
find_package(BZip2 QUIET)
# dep/lualib (the Lua build used by Eluna) links against readline by its bare
# library name and is not itself touched here; find_package(Readline) declares a
# GLOBAL IMPORTED target literally named `readline` (see cmake/FindReadline.cmake)
# before that subdirectory is added, so its existing bare-name references resolve
# to a properly-detected library instead of an unqualified linker search -- which
# is what fails on FreeBSD, where readline lives in /usr/local/lib.
if(NOT WIN32 AND SCRIPT_LIB_ELUNA)
find_package(Readline REQUIRED)
endif()
find_package(OpenSSL 3.0 REQUIRED)
# OpenSSL 4.x support is intentionally deferred until the OpenSSL 4.2 LTS migration.
if(OPENSSL_VERSION VERSION_GREATER_EQUAL "4.0.0")
message(FATAL_ERROR
"Unsupported OpenSSL ${OPENSSL_VERSION}: MaNGOS currently requires >=3.0.0 and <4.0.0")
endif()
# =============================================================================
# OpenSSL policy
#
# OpenSSL 3.x is the baseline: there are no version conditionals left in src/.
# Every OpenSSL decision lives here, in two interface targets:
#
# mangos_openssl - what to link against and where the headers live.
# Linked by anything that touches OpenSSL types
# (Auth, Warden) so consumers inherit it.
#
# mangos_openssl_strict - the API level we hold ourselves to. Together these
# two definitions delete the *declarations* of
# everything OpenSSL deprecated up to 3.0 -- the
# low-level MD5_*, SHA1_*, HMAC_CTX and SSLeay_*
# families. Reaching for the old API is then a
# compile error rather than a warning nobody reads.
#
# Link it PRIVATE, always: it must not leak into the
# vendored code under dep/, which still uses the old API.
# =============================================================================
add_library(mangos_openssl INTERFACE)
target_link_libraries(mangos_openssl
INTERFACE
OpenSSL::SSL
OpenSSL::Crypto
)
add_library(mangos_openssl_strict INTERFACE)
target_compile_definitions(mangos_openssl_strict
INTERFACE
OPENSSL_API_COMPAT=0x30000000L
OPENSSL_NO_DEPRECATED
)
# =============================================================================
# Network backend selection
#
# Detection lives here, next to the option, rather than in src/shared: the result
# is needed by the build summary at the end of this file, and a set() inside a
# subdirectory would not be visible up here.
#
# Off by default -- the epoll reactor is the supported Linux backend and liburing
# is absent on plenty of distributions. Asking for it without the headers present
# is not fatal; it warns and falls back, which is why the summary prints the
# backend that was actually chosen rather than the one that was requested.
# =============================================================================
set(MANGOS_USE_IO_URING OFF)
if(WITH_IO_URING AND UNIX AND NOT APPLE)
find_library(URING_LIBRARY NAMES uring)
find_path(URING_INCLUDE_DIR NAMES liburing.h)
if(URING_LIBRARY AND URING_INCLUDE_DIR)
set(MANGOS_USE_IO_URING ON)
else()
message(WARNING "WITH_IO_URING was requested but liburing was not found; "
"falling back to the epoll reactor.")
endif()
endif()
include(${CMAKE_SOURCE_DIR}/cmake/GenRevision.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/EnsureVersion.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/MangosParams.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/SetDefinitions.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/SubmoduleCompat.cmake)
if(PCH)
include(${CMAKE_SOURCE_DIR}/cmake/PCHSupport.cmake)
endif()
include(${CMAKE_SOURCE_DIR}/cmake/Dependencies.cmake)
if(WITH_TESTS OR WITH_NET_TESTS)
set(BUILD_TESTING ON)
enable_testing()
endif()
add_subdirectory(src)
include(${CMAKE_SOURCE_DIR}/cmake/StatusInfo.cmake)