forked from desura/desura-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
374 lines (315 loc) · 13 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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
###############################################################################
#
# you can pass some options to cmake via -D<option>[=<value>]
#
# name default description
#
# global options:
# BUILD_CEF ON Build cef
# BUILD_TESTS ON Build various unit tests
# WITH_GTEST ON Add GTest support
# WITH_GMOCK ON Add GMock support (note: WITH_GTEST must be on)
# WITH_CODESIGN OFF Check code sign on dlls/exe (WIN32 Only)
# BUILD_TOOLS ON Build various Desura tools
# OFFICIAL_BUILD OFF for official build only
# BRANDING depends on which branding should be used?
# OFFICIAL_BUILD
# DEBUG OFF will add debug symbols and other
# debugging stuff
# PACKAGE_TYPE DEB Which packages should be created with "make package"
# FORCE_SYS_DEPS OFF Force the use of system libs
# WITH_FLASH ON Build with flash support
# WITH_TRACING ON (WIN32) Build with tracing support
#
# BREAKPAD_URL URL to breakdpad archive, should be rev. 850
# CEF_URL URL to cef archive, should be rev. 291
# CEF_BIN_URL URL to cef bin files for windows
# CHROMIUM_URL URL to chromium archive, has to be 15.0.876.0
# CURL_URL URL to curl archive
# DEPOT_TOOLS_URL URL to depot_tools archive
# V8_URL URL to v8 archive
# WXWIDGET_URL URL to wxWidget archive, has to be 3.0.0
#
# cef options:
# H264_SUPPORT OFF build ffmpeg with mpeg-4 support. Be aware of patent and license problems
#
# installation options:
# BINDIR ./bin the directory where binaries should be installed, a relative path will be
# relative to CMAKE_INSTALL_PREFIX, an absolute will stay absolute
# RUNTIME_LIBDIR ./lib/desura the directory where runtime loaded libs should be stored
# DATADIR ./share/desura same as RUNTIME_LIBDIR only for data files
# DESKTOPDIR depends on OS the directory where the desktop file or link should be installed
#
# unix-only options:
# FORCE_BUNDLED_WXGTK ON: bundle wxGTK 3.0.0
# FORCE_BUNDLED_BOOST ON: bundle boost
# OFF OFF: use system wxGTK (has to be 3.0.0 or later)
# DEBUG_EXTERNAL OFF same as DEBUG, but for externap deps
# DIR_TYPE SINGLE how should game data be stored?
# SINGLE: in a single dir in $HOME
# XDG: like the official xdg specification
# PORTABLE: in the desura installaion dir
# INSTALL_DESKTOP_FILE INSTALL a desktop file in /usr/share/applications
# OFF
#
# Linux-only options:
# DESKTOP_EXE desura the value of Exe in the desktop file
# DESKTOP_ICON desura the value of Icon in the desktop file
#
# wxWidgets select correct version
# wxWidgets_CONFIG_EXECUTABLE path to wx-config (version 3.0.0 or later)
# wxWidgets_wxrc_EXECUTABLE path to wxrc (version 3.0.0 or later)
#
# windows-only options:
# BOOST_URL URL to boost archive
# DEBUG_CEF OFF turn on/off debugging in CEF
# DEBUG_V8 OFF turn on/off debugging in v8
#
# some dev notes:
#
# if you want to port desura to another compiler on UNIX bases systems,
# please create a file for compiler flags in:
#
# cmake/platform/unix/compiler/${CMAKE_C_COMPILER_ID}.cmake
#
# Take a look into the other files.
#
###############################################################################
###############################################################################
# some overrides
###############################################################################
# TODO: silent output for external dependencies
project(Desura)
if(APPLE)
# see #418
cmake_minimum_required(VERSION 2.8.10)
elseif(WIN32)
#needed for x120_xp target
cmake_minimum_required(VERSION 2.8.12)
else()
cmake_minimum_required(VERSION 2.8.5)
endif()
###############################################################################
# some global variables
###############################################################################
set(CEF_EXTERNAL_PATH "" CACHE STRING "External path to cef if building separately to desura")
set(CMAKE_OUTPUT "${CMAKE_SOURCE_DIR}/build_out")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
set(CMAKE_PLATFORM_PATH "${CMAKE_SOURCE_DIR}/cmake/platform")
set(CMAKE_EXTERNAL_BINARY_DIR "${CMAKE_BINARY_DIR}/external")
set(CMAKE_THIRD_PARTY_DIR "${CMAKE_SOURCE_DIR}/third_party")
set(CMAKE_SCRIPT_PATH "${CMAKE_SOURCE_DIR}/cmake/scripts")
set(CMAKE_PATCH_DIR "${CMAKE_SOURCE_DIR}/cmake/patches")
set(CMAKE_GEN_SRC_DIR "${CMAKE_BINARY_DIR}/gen")
set(CMAKE_TEST_PROJECTS "${CMAKE_SOURCE_DIR}/cmake/tests")
set(CMAKE_TEST_PROJECTS_BIN "${CMAKE_BINARY_DIR}/cmake_test")
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
if(WIN32)
if(DEBUG)
set(CMAKE_BUILD_TYPE Debug)
else()
if(OFFICIAL_BUILD)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
else()
set(CMAKE_BUILD_TYPE Release)
endif()
endif()
endif()
if(OFFICIAL_DEBUG_BUILD)
set(CMAKE_BUILD_TYPE Debug)
endif()
###############################################################################
# some includes
###############################################################################
include(CheckOptions)
include(ExternalProject)
include(macros)
include(parsearguments)
include(CheckCompiler)
include(SetInstallPaths)
include(Package)
if(UNIX)
include(FindPkgConfig)
endif()
###############################################################################
# find all packages which are needed
###############################################################################
if(NOT WIN32)
set(REQUIRED_ON_UNIX REQUIRED)
endif()
if(NOT BUILD_ONLY_CEF)
set(Boost_USE_MULTITHREADED ON)
if(WIN32)
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_STATIC_RUNTIME OFF)
endif()
if(NOT FORCE_BUNDLED_BOOST)
find_package(Boost COMPONENTS filesystem system)
else()
set(Boost_FOUND OFF)
endif()
if(NOT FORCE_BUNDLED_CURL)
find_package(CURL 7.19.1 ${REQUIRED_IF_OPTION})
else()
set(CURL_FOUND OFF)
endif()
if(NOT WIN32)
find_package(GTK2 REQUIRED)
find_package(X11 REQUIRED)
if(NOT X11_Xt_FOUND)
message(FATAL_ERROR "libXt is required")
endif()
pkg_check_modules(GTHREAD2 REQUIRED gthread-2.0)
find_package(Threads)
find_package(Notify REQUIRED)
if(NOT HAVE_LIBNOTIFY_0_7)
message(FATAL_ERROR "libnotify >= 0.7 is required")
endif()
find_package(TinyXML)
endif()
find_package(BZip2 ${REQUIRED_IF_OPTION})
find_package(Sqlite ${REQUIRED_IF_OPTION})
if(NOT FORCE_BUNDLED_WXGTK)
find_package(wxWidgets 3.0 COMPONENTS richtext ${REQUIRED_IF_OPTION})
if(wxWidgets_FOUND)
try_compile(
WXWIDGET_3_0_TEST_COMPILE
"${CMAKE_TEST_PROJECTS_BIN}/wxWidget_3.0_test"
"${CMAKE_TEST_PROJECTS}/wxWidget_3.0_test"
"wxWidget_3_0_test"
"wxWidget_3_0_test"
CMAKE_FLAGS
"-DwxWidgets_CONFIG_EXECUTABLE=${wxWidgets_CONFIG_EXECUTABLE}"
"-DwxWidgets_wxrc_EXECUTABLE=${wxWidgets_wxrc_EXECUTABLE}")
if(NOT WXWIDGET_3_0_TEST_COMPILE)
unset(wxWidgets_FOUND)
message(STATUS "no wxWidget 3.0 found")
endif()
endif()
endif()
if(WITH_GTEST)
find_package(GTest 1.7 ${REQUIRED_IF_OPTION})
add_definitions(-DGTEST_LINKED_AS_SHARED_LIBRARY -DWITH_GTEST)
endif()
if(WITH_GTEST AND WITH_GMOCK)
find_package(GMock 1.7 ${REQUIRED_IF_OPTION})
add_definitions(-DGMOCK_LINKED_AS_SHARED_LIBRARY -DWITH_GMOCK)
endif()
if (WITH_TRACING)
add_definitions(-DWITH_TRACING)
endif()
endif()
find_package(PythonInterp REQUIRED)
if(WIN32)
find_package(PythonLibs REQUIRED)
endif()
find_package(Patch REQUIRED)
if(MSVC)
configure_file(${CMAKE_SCRIPT_PATH}/patch.bat ${CMAKE_GEN_SRC_DIR}/scripts/patch.bat @ONLY)
set(PATCH_SCRIPT_PATH ${CMAKE_GEN_SRC_DIR}/scripts/patch.bat)
else()
set(PATCH_SCRIPT_PATH ${CMAKE_SCRIPT_PATH}/patch.sh)
endif()
if(WIN32)
find_package(NMake REQUIRED)
endif()
###############################################################################
# SVN, HTTP stuff
###############################################################################
set(DOWNLOAD_URL "http://s3.desura.com.s3-website-us-west-2.amazonaws.com/build/" CACHE STRING "Download mirror for third party source code and binaries")
macro(SetupDownloadUrlCustom name url md5)
set(${name}_URL_DEFAULT "${url}")
set(${name}_URL ${${name}_URL_DEFAULT} CACHE STRING "URL to get ${name} archive")
if(${name}_URL STREQUAL ${name}_URL_DEFAULT)
set(${name}_MD5 ${md5} CACHE STRING "Md5 for ${name} archive")
else()
unset(${name}_MD5)
endif()
endmacro()
macro(SetupDownloadUrl name url md5)
SetupDownloadUrlCustom(${name} "${DOWNLOAD_URL}${url}" ${md5})
endmacro()
# custom dll's for Desura
if(WIN32)
SetupDownloadUrl(CEF_BIN "cef_bin_2.zip" ec737b15c3c90f5c43d26c4e22f5dfcc)
SetupDownloadUrl(DESURA_EXTRA_BIN "desura_extra_bin_v3.zip" 79bd00407c682c6b1dab5c7fb65ba72e)
endif()
###### SetupDownloadUrl(BOOST "boost_1_55_0.zip" 8aca361a4713a1f491b0a5e33fee0f1f)
SetupDownloadUrlCustom(BOOST "http://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.zip/download" 8aca361a4713a1f491b0a5e33fee0f1f)
# live code
SetupDownloadUrl(BREAKPAD "breakpad-850-r1.zip" b0061a854df1a0d285edc74c5ac37c42)
# no longer available (too old)
SetupDownloadUrl(CEF "cef-291.tar.gz" 97e925e33f2d48cd50172247dbe40f30)
# 3 years out of date (chromium.org) Also not clear how this is used.
SetupDownloadUrl(CHROMIUM "chromium-15.0.876.0.tar.bz2" 22c8e1db4d1c4b474c600dffbb5fdd0c)
# no longer available (too old, but 7.39 is available)
#SetupDownloadUrl(CURL "curl-7.32.0.tar.bz2" 30d04b0a8c43c6770039d1bf033dfe79)
SetupDownloadUrlCustom(CURL "http://curl.haxx.se/download/curl-7.39.0.tar.gz" 88c5650122873712296d4b1db3f12e6c)
# (chromium depot tools, also OLD - source: http://src.chromium.org/svn/trunk/tools/depot_tools/ )
SetupDownloadUrl(DEPOT_TOOLS "depot_tools-r1.zip" a27266b8d2388c4dc51645d1159dd0de)
###### SetupDownloadUrl(GTEST "gtest-1.7.0.zip" 2d6ec8ccdf5c46b05ba54a9fd1d130d7)
SetupDownloadUrlCustom(GTEST "https://googletest.googlecode.com/files/gtest-1.7.0.zip" 2d6ec8ccdf5c46b05ba54a9fd1d130d7)
###### SetupDownloadUrl(GMOCK "gmock-1.7.0.zip" 073b984d8798ea1594f5e44d85b20d66)
SetupDownloadUrlCustom(GMOCK "https://googlemock.googlecode.com/files/gmock-1.7.0.zip" 073b984d8798ea1594f5e44d85b20d66)
# live code: https://code.google.com/p/v8/source/browse#svn%2Fbranches%2F3.18
SetupDownloadUrl(V8 "v8-3.18.5.14.tar.bz2" 657802ea63c89190fd510ee1a2a719bf)
###### SetupDownloadUrl(WXWIDGET "wxWidgets-3.0.0.tar.bz2" 241998efc12205172ed24c18788ea2cd)
SetupDownloadUrlCustom(WXWIDGET "http://downloads.sourceforge.net/project/wxwindows/3.0.2/wxWidgets-3.0.2.tar.bz2" ba4cd1f3853d0cd49134c5ae028ad080)
###############################################################################
# build some external projects
###############################################################################
if(NOT BUILD_ONLY_CEF)
if(NOT wxWidgets_FOUND)
include(BuildwxWidgets)
endif()
if(NOT Boost_FOUND OR FORCE_BUNDLED_BOOST)
include(BuildBoost)
endif()
if(NOT BREAKPAD_EXCEPTION_HANDLER_FOUND)
include(BuildGoogleBreakpad)
endif()
if(NOT CURL_FOUND)
include(BuildCURL)
endif()
if(NOT GTEST_FOUND AND WITH_GTEST)
include(BuildGTest)
endif()
if(NOT GMOCK_FOUND AND WITH_GTEST AND WITH_GMOCK)
include(BuildGMock)
endif()
include(Buildv8)
if(WIN32)
include(BuildDesuraExtraBin)
endif()
endif()
include(BuildCEF)
if(NOT BUILD_ONLY_CEF)
###############################################################################
# build third_party
###############################################################################
if(NOT BZIP2_FOUND)
add_subdirectory(third_party/bzip2)
endif()
add_subdirectory(third_party/courgette) # for headers only, build via ExternalProject
if(NOT TINYXML_FOUND)
add_subdirectory(third_party/tinyxml2)
endif()
if(NOT SQLITE_FOUND)
add_subdirectory(third_party/sqlite)
endif()
add_subdirectory(third_party/sqlite3x)
if(NOT Boost_FOUND)
add_dependencies(sqlite3x boost)
endif()
if(WITH_FLASH AND NOT WIN32)
add_subdirectory(third_party/npwrapper)
endif()
###############################################################################
# build desura
###############################################################################
add_subdirectory(src)
add_subdirectory(build_out)
endif()
if(NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -Wall -Weffc++")
endif()