-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
263 lines (220 loc) · 6.77 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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# Copyright (C) 2005-2010 Trinity <http://www.trinitycore.org/>
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
project(Trinity)
# CMake policies
cmake_minimum_required(VERSION 2.6)
cmake_policy(SET CMP0005 OLD)
#
# Override configuration-types - we don't use anything else than debug and release
#
if(CMAKE_CONFIGURATION_TYPES)
set(CMAKE_CONFIGURATION_TYPES Debug Release)
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
"Reset the configurations to what we need"
FORCE)
endif()
# Force out-of-source build
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" BUILDING_IN_SOURCE)
if( BUILDING_IN_SOURCE )
message(FATAL_ERROR "
This project requires an out of source build. Remove the file 'CMakeCache.txt'
found in this directory before continuing, create a separate build directory
and run 'cmake path_to_project [options]' from there.
")
endif()
#
# Basic packagesearching and setup (further support will be needed, this is a preliminary release!)
#
include(CheckIncludeFiles)
include(cmake/FindPlatform.cmake)
include(cmake/FindPCHSupport.cmake)
if(WIN32)
set(ACE_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/externals)
endif()
include(cmake/FindACE.cmake)
include(cmake/FindMySQL.cmake)
include(cmake/FindOpenSSL.cmake)
#
# *nix-specific packages ( zlib and bzip2 libraries will be built from sourcetree on WIN32-platforms)
#
if( UNIX )
include(cmake/FindReadline.cmake)
include(cmake/FindTermcap.cmake)
include(FindZLIB)
include(FindBZip2)
endif()
# Select the Release build configuration by default.
if( NOT CMAKE_BUILD_TYPE )
set(CMAKE_BUILD_TYPE "Release")
endif()
if( UNIX )
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY
)
add_custom_target(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
)
endif()
option(AUTHSERVER "Build authserver" 1)
option(WORLDSERVER "Build worldserver" 1)
option(CLI "With CLI" 1)
option(DEBUG "Debug mode" 0)
option(PCH "Use precompiled headers" 1)
option(SCRIPTS "With trinityscripts" 1)
option(SQL "Copy SQL files" 0)
option(TOOLS "Build tools" 0)
option(WARNINGS "Enable all compile warnings" 0)
if( UNIX )
option(CENTOS "CENTOS" 0)
if( CENTOS )
add_definitions(-DCENTOS)
find_termcap()
else()
find_readline()
endif()
endif()
# Set up the installation-prefix
if( PREFIX )
set(CMAKE_INSTALL_PREFIX ${PREFIX})
endif()
set(GENREV_SRC
src/genrevision/genrevision.cpp
)
# Handle debugmode compiles (this will require further work for proper WIN32-setups)
if( DEBUG )
set(CMAKE_BUILD_TYPE Debug)
endif()
#
# Generate revision-extractor
#
add_executable(genrev
${GENREV_SRC}
)
if( CMAKE_GENERATOR MATCHES "Visual Studio" )
add_custom_target("revision.h" ALL
COMMAND "${CMAKE_BINARY_DIR}/$(ConfigurationName)/genrev"
${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
DEPENDS genrev
)
else()
add_custom_target("revision.h" ALL
COMMAND "${CMAKE_BINARY_DIR}/genrev"
${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
DEPENDS genrev
)
endif()
execute_process(
COMMAND hg tip --template {rev}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE HG_REVISION
)
message("")
message("* TrinityCore revision : ${HG_REVISION}")
message("* Build binaries in : ${CMAKE_BUILD_TYPE} mode")
message("")
if( NOT CONF_DIR )
set(CONF_DIR ${CMAKE_INSTALL_PREFIX}/etc)
endif()
set(LIBSDIR ${CMAKE_INSTALL_PREFIX}/lib)
message("* Install core to : ${CMAKE_INSTALL_PREFIX}")
message("* Install libraries to : ${LIBSDIR}")
message("* Install configs to : ${CONF_DIR}")
message("")
if( AUTHSERVER )
message("* Build authserver : Yes (default)")
else()
message("* Build authserver : No")
endif()
if( WORLDSERVER )
message("* Build worldserver : Yes (default)")
else()
message("* Build worldserver : No")
endif()
if( SCRIPTS )
message("* Build Trinityscripts : Yes (default)")
add_definitions(-DSCRIPTS)
else()
message("* Build Trinityscripts : No")
endif()
if( TOOLS )
message("* Build map/vmap tools : Yes")
else()
message("* Build map/vmap tools : No (default)")
endif()
if( CLI )
message("* Build with CLI : Yes (default)")
add_definitions(-DENABLE_CLI)
else()
message("* Build with CLI : No")
endif()
if( DEBUG )
message("* Build in debug-mode : Yes")
add_definitions(-g -DTRINITY_DEBUG)
else()
message("* Build in debug-mode : No (default)")
endif()
if( PCH )
message("* Use PCH : Yes (default)")
else()
message("* Use PCH : No")
endif()
if( WARNINGS )
message("* Show all warnings : Yes")
if( UNIX )
add_definitions(-Wall -Wfatal-errors -Wextra)
endif()
else()
message("* Show compile-warnings : No (default)")
if( UNIX )
add_definitions(--no-warnings) # makes build look nice, no warnings shown at all, only errors
elseif( WIN32 )
# Disable warnings in Visual Studio 8 and above
if(MSVC AND NOT CMAKE_GENERATOR MATCHES "Visual Studio 7")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /wd4996 /wd4355 /wd4244 /wd4985 /wd4267")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /wd4996 /wd4355 /wd4244 /wd4267")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /wd4996 /wd4355 /wd4244 /wd4985 /wd4267")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /wd4996 /wd4355 /wd4244 /wd4985 /wd4267")
endif()
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
endif()
if( SQL )
message("* Install SQL-files : Yes")
else()
message("* Install SQL-files : No (default)")
endif()
message("")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
# Little tweak for OS X
if( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
set(MACOSX 1)
set(OSX_LIBS /opt/local/lib/libcrypto.dylib)
add_definitions(-D__ASSERTMACROS__)
endif()
# Some small tweaks for Visual Studio 7 and above.
if( MSVC )
# Mark 32 bit executables large address aware so they can use > 2GB address space
if(CMAKE_SIZEOF_VOID_P MATCHES 4)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
endif()
endif()
set(CMAKE_SKIP_BUILD_RPATH 0)
set(CMAKE_BUILD_WITH_INSTALL_RPATH 0)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH 1)
add_subdirectory(externals)
add_subdirectory(src)
if( SQL )
add_subdirectory(sql)
endif()