forked from ProjectSkyfire/SkyFire.406a
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
331 lines (271 loc) · 7.72 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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# 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.
#####
##### Base setup for project
#####
#
# Set projectname (must be done AFTER setting configurationtypes btw...)
#
project(TrinityCore)
# CMake policies
cmake_minimum_required(VERSION 2.6)
cmake_policy(SET CMP0005 OLD)
#
# 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}/dep/acelite)
endif()
include(cmake/FindACE.cmake)
include(cmake/FindMySQL.cmake)
include(cmake/FindOpenSSL.cmake)
if( UNIX )
include(cmake/FindReadline.cmake)
include(FindZLIB)
include(FindBZip2)
endif()
#
# Select the Release build configuration by default.
#
if( NOT CMAKE_BUILD_TYPE )
set(CMAKE_BUILD_TYPE "Release")
endif()
#####
##### Options and settings
#####
#
# Set up default option-parameters for building
#
option(SERVERS "Build worldserver and authserver" 1)
option(SCRIPTS "Build worldserver with scripts included" 1)
option(TOOLS "Build map/vmap extraction/assembler tools" 0)
option(COREDEBUG "Build worldserver with additional debug-code included" 0)
option(SCRIPTPCH "Use precompiled headers when compiling scripts project" 1)
option(GAMEPCH "Use precompiled headers when compiling game project" 1)
option(SQL "Copy SQL files during installation" 0)
option(WARNINGS "Enable all compile-warnings during compile" 0)
#
# Search for readline on *nixbased systems (CLI-handler)
#
if( UNIX )
find_readline()
endif()
#
# Set up the installation-prefix
#
if( PREFIX )
set(CMAKE_INSTALL_PREFIX "${PREFIX}")
endif()
#
# Example: Check the CMake preload parameters (Commented out by default)
#
# Overload CMAKE_INSTALL_PREFIX if not being set properly
#if( WIN32 )
# if( NOT CYGWIN )
# if( NOT CMAKE_INSTALL_PREFIX )
# set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/bin")
# endif()
# endif()
#endif()
#
# Handle core debugmode compilation (this will require further work for proper WIN32-setups)
#
if( COREDEBUG )
set(CMAKE_BUILD_TYPE Debug)
endif()
#
# WINDOWS/MSVC: Set up paths for where we want binaries to end up after compilation
#
if( MSVC )
# Set up MSVC to dump files in the <builddir>/bin/<buildtype>/ folder for testing builds before install
# executable binaries (.exe-files, and .dll-files on DLL-capable platforms)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# other parts like static libraries etc - commented out as it's not needed - shown here as an example only
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
endif()
#
# Set default configuration-directory (used on NIX-based platforms only)
#
if( NOT CONF_DIR )
set(CONF_DIR ${CMAKE_INSTALL_PREFIX}/etc)
endif()
set(LIBSDIR ${CMAKE_INSTALL_PREFIX}/lib)
#####
##### Build-preparation
#####
#
# Create genrev object and create revision.h
# (Moved to subfolder to avoid cluttering up the base build-dir)
#
add_subdirectory(src/genrevision)
#
# Find current revision of downloaded sourcetree
#
execute_process(
COMMAND hg tip --template {rev}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE HG_REVISION
)
if(DEFINED NOPCH)
set(SCRIPTPCH 0)
set(GAMEPCH 0)
endif()
#
# Output some generic information about the core and buildtype chosen
#
message("")
message("* TrinityCore revision : ${HG_REVISION}")
if( UNIX )
message("* Build binaries in : ${CMAKE_BUILD_TYPE} mode")
endif()
message("")
#
# Output information about installation-directories and locations
#
message("* Install core to : ${CMAKE_INSTALL_PREFIX}")
if( UNIX )
message("* Install libraries to : ${LIBSDIR}")
message("* Install configs to : ${CONF_DIR}")
endif()
message("")
#
# Show infomation about the options selected during configuration
#
if( SERVERS )
message("* Build servers : Yes (default)")
else()
message("* Build servers : No")
endif()
if( GAMEPCH )
message("* Build game w/PCH : Yes (default)")
else()
message("* Build game w/PCH : No")
endif()
if( SCRIPTS )
message("* Build with scripts : Yes (default)")
add_definitions(-DSCRIPTS)
else()
message("* Build with scripts : No")
set(SCRIPTPCH 0)
endif()
if( SCRIPTPCH )
message("* Build scripts w/PCH : Yes (default)")
else()
message("* Build scripts w/PCH : No")
endif()
if( TOOLS )
message("* Build map/vmap tools : Yes")
else()
message("* Build map/vmap tools : No (default)")
endif()
if( COREDEBUG )
message("* Use coreside debug : Yes")
add_definitions(-DTRINITY_DEBUG)
if(CMAKE_COMPILER_IS_GNUCXX)
add_definitions(-g)
endif()
else()
message("* Use coreside debug : No (default)")
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 "${CMAKE_C_FLAGS} /wd4996 /wd4355 /wd4244 /wd4985 /wd4267 /wd4619")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996 /wd4355 /wd4244 /wd4985 /wd4267 /wd4619")
endif()
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
endif()
#
# Inform if we will install SQL-files or not
#
if( SQL )
message("* Install SQL-files : Yes")
else()
message("* Install SQL-files : No (default)")
endif()
message("")
#####
##### Tweaks to make things operate well
#####
#
# Little tweak for OS X
#
if( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
set(MACOSX 1)
set(OSX_LIBS /usr/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()
# Multithreaded compiling on VS
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
endif()
#
# Set RPATH-handing (CMake parameters)
#
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)
#####
##### Start filling in the blanks, and build the project
#####
#
# Create uninstall-object for UNIX platforms
#
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()
#
# Enter the different builddirectories and start working
#
add_subdirectory(dep)
add_subdirectory(src)
if( SQL )
add_subdirectory(sql)
endif()