forked from copperspice/copperspice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
448 lines (390 loc) · 14.6 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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
cmake_minimum_required(VERSION 3.4.3 FATAL_ERROR)
cmake_policy(SET CMP0042 NEW)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
project(copperspice)
include(CheckCXXCompilerFlag)
include(CheckCXXSourceCompiles)
include(CheckIncludeFile)
include(CheckIncludeFiles)
include(CheckTypeSize)
include(FeatureSummary)
include(CopperSpiceBuildMacros)
include(TestLargeFiles)
# location deploy or install
if(UNIX)
include(GNUInstallDirs)
else()
set(CMAKE_INSTALL_BINDIR bin)
set(CMAKE_INSTALL_LIBDIR lib)
set(CMAKE_INSTALL_INCLUDEDIR include)
endif()
set(BUILD_MAJOR "1")
set(BUILD_MINOR "5")
set(BUILD_MICRO "1")
set(BUILD_ABI ${BUILD_MAJOR}.${BUILD_MINOR})
# required library
set(BUILD_COMPONENTS "Core")
# might add DBus, Declarative and ScriptTools later
set(_OPTIONAL_COMPONENTS Gui Multimedia Network OpenGL Phonon Script Sql Svg WebKit Xml XmlPatterns)
set(PACKAGE "copperspice")
set(PACKAGE_NAME "copperspice")
set(PACKAGE_VERSION "${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_MICRO}")
set(PACKAGE_STRING "copperspice ${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_MICRO}")
set(PACKAGE_TARNAME "copperspice")
set(PACKAGE_BUGREPORT "[email protected]")
set(PACKAGE_URL "http://www.copperspice.com/")
# used in cs_build_info.h.in
set(HEX_VERSION "0x0${BUILD_MAJOR}0${BUILD_MINOR}0${BUILD_MICRO}")
set(VERSION "${PACKAGE_VERSION}")
set(prefix "${CMAKE_INSTALL_PREFIX}")
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang|AppleClang)")
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine
OUTPUT_VARIABLE DUMPMACHINE_OUTPUT
RESULT_VARIABLE DUMPMACHINE_EXITCODE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT DUMPMACHINE_EXITCODE EQUAL 0)
message(SEND_ERROR "Failed to obtain machine from ${CMAKE_CXX_COMPILER}")
endif()
set(target "${DUMPMACHINE_OUTPUT}")
elseif(MSVC)
enable_language(ASM_MASM)
set(target "MSVC")
else()
message(WARNING
"Your compiler (${CMAKE_CXX_COMPILER}) may not be supported. "
"The plugin key which will be used is: ${CMAKE_SYSTEM}"
)
set(target "${CMAKE_SYSTEM}")
endif()
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_PACKAGE_VENDOR "CopperSpice")
set(CPACK_PACKAGE_VERSION_MAJOR ${BUILD_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${BUILD_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${BUILD_MICRO})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "C++ GUI library")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")
set(CPACK_SOURCE_IGNORE_FILES "/build/;/.git;${CPACK_SOURCE_IGNORE_FILES}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX})
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
include(CPack)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 14)
if(APPLE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-undefined,error")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-undefined,error")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-undefined,error")
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined")
endif()
string(TIMESTAMP BUILD_DATE "%Y-%m-%d")
add_definitions(-DQT_SHARED -DBUILD_DATE="${BUILD_DATE}")
set(TOOLS_SUFFIX)
check_include_file(cups/cups.h HAVE_CUPS_CUPS_H)
check_include_file(features.h HAVE_FEATURES_H)
check_include_file(pthread.h HAVE_PTHREAD_H)
check_include_file(pthread_np.h HAVE_PTHREAD_NP_H)
check_include_file(unistd.h HAVE_UNISTD_H)
check_include_file(dirent.h HAVE_DIRENT_H)
check_include_file(fcntl.h HAVE_FCNTL_H)
check_include_file(grp.h HAVE_GRP_H)
check_include_file(pwd.h HAVE_PWD_H)
check_include_file(signal.h HAVE_SIGNAL_H)
check_include_file(dlfcn.h HAVE_DLFCN_H)
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(sys/ioctl.h HAVE_SYS_IOCTL_H)
check_include_file(sys/ipc.h HAVE_SYS_IPC_H)
check_include_file(sys/time.h HAVE_SYS_TIME_H)
check_include_file(sys/shm.h HAVE_SYS_SHM_H)
check_include_file(sys/socket.h HAVE_SYS_SOCKET_H)
check_include_file(sys/stat.h HAVE_SYS_STAT_H)
check_include_file(sys/wait.h HAVE_SYS_WAIT_H)
check_include_file(sys/param.h HAVE_SYS_PARAM_H)
check_include_file(netinet/in.h HAVE_NETINET_IN_H)
check_include_file(net/if.h HAVE_NET_IF_H)
check_include_file(inttypes.h HAVE_INTTYPES_H)
check_include_file(libpq-fe.h HAVE_LIBPQ_FE_H)
check_include_file(pg_config.h HAVE_PG_CONFIG_H)
check_include_file(memory.h HAVE_MEMORY_H)
check_include_file(mysql/mysql.h HAVE_MYSQL_H)
check_include_file(stdint.h HAVE_STDINT_H)
check_include_file(stdlib.h HAVE_STDLIB_H)
check_include_file(strings.h HAVE_STRINGS_H)
check_include_file(string.h HAVE_STRING_H)
check_include_files("dlfcn.h;stdint.h;stddef.h;inttypes.h;stdlib.h;strings.h;string.h;float.h" STDC_HEADERS)
check_type_size(size_t SIZEOF_SIZE_T)
opj_test_large_files(HAVE_LARGEFILESUPPORT)
option(WITH_PSQL_PLUGIN "Build PostgreSQL database plugin (if possible)" ON)
add_feature_info(PostgreSQL WITH_PSQL_PLUGIN "Popular open source database")
option(WITH_MYSQL_PLUGIN "Build MySQL database plugin (if possible)" ON)
add_feature_info(MySQL WITH_MYSQL_PLUGIN "Popular open source database")
foreach(component ${_OPTIONAL_COMPONENTS})
string(TOUPPER ${component} uppercomp)
option(WITH_${uppercomp} "Build ${component} component" ON)
endforeach()
message("")
message(STATUS "Search for packages:\n")
find_package(OpenSSL 1.0)
set_package_properties(OpenSSL PROPERTIES
PURPOSE "Required for HTTPS support"
DESCRIPTION "Support for secure network communications using OpenSSL for SSL and TLS"
URL "http://openssl.org"
TYPE RECOMMENDED
)
find_package(ZLIB)
set_package_properties(ZLIB PROPERTIES
PURPOSE "Required for compression support"
DESCRIPTION "A compression Library"
URL "http://zlib.net"
TYPE RECOMMENDED
)
find_package(Cups)
set_package_properties(Cups PROPERTIES
PURPOSE "Required for printing support"
DESCRIPTION "CUPS is the standards-based open source printing system"
URL "http://www.cups.org"
TYPE RECOMMENDED
)
find_package(ALSA)
set_package_properties(ALSA PROPERTIES
PURPOSE "Required for ALSA audio support"
DESCRIPTION "Advanced Linux Sound Architecture"
URL "http://www.alsa-project.org"
TYPE RECOMMENDED
)
find_package(PostgreSQL)
set_package_properties(PostgreSQL PROPERTIES
PURPOSE "Required for PostgreSQL database support"
DESCRIPTION "Popular open source database"
URL "http://www.postgresql.org"
TYPE RECOMMENDED
)
find_package(MySQL)
set_package_properties(MySQL PROPERTIES
PURPOSE "Required for MySQL database support"
DESCRIPTION "Popular open source database"
URL "http://www.mysql.com"
TYPE RECOMMENDED
)
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
find_package(GTK2)
set_package_properties(GTK2 PROPERTIES
PURPOSE "Required for GTK style and application integration support"
DESCRIPTION "Multi-platform toolkit for creating graphical user interfaces"
URL "http://www.gtk.org"
TYPE RECOMMENDED
)
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
find_package(Security)
set_package_properties(Security PROPERTIES
PURPOSE "Required for HTTPS support"
DESCRIPTION "Support for secure network communications using Secure Trasnport for SSL and TLS"
URL "https://developer.apple.com/documentation/security/secure_transport"
TYPE RECOMMENDED
)
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "(Linux|OpenBSD|FreeBSD|NetBSD|DragonFly)")
# required by core component
find_package(Threads)
set_package_properties(Threads PROPERTIES
PURPOSE "Required for threading support"
DESCRIPTION "Platform dependant threading library"
URL ""
TYPE REQUIRED
)
find_package(GLib2)
set_package_properties(GLib2 PROPERTIES
PURPOSE "Required for glib mainloop support"
DESCRIPTION "Core application building blocks for libraries and applications written in C"
URL "https://developer.gnome.org/glib"
TYPE REQUIRED
)
find_package(GOBJECT2)
set_package_properties(GOBJECT2 PROPERTIES
PURPOSE "Required for glib mainloop support"
DESCRIPTION "The object system used for Pango and GTK+"
URL "https://developer.gnome.org/gobject"
TYPE REQUIRED
)
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
find_package(Iconv)
set_package_properties(Iconv PROPERTIES
PURPOSE "Iconv support"
DESCRIPTION "iconv() implementation, for use on systems which do not have one or lack Unicode support"
URL "http://www.gnu.org/software/libiconv/"
TYPE REQUIRED
)
endif()
if(WITH_GUI)
find_package(NAS)
set_package_properties(NAS PROPERTIES
PURPOSE "Required for basic audio support"
DESCRIPTION "Network transparent, client/server audio transport system"
URL "http://www.radscan.com/nas.html"
TYPE REQUIRED
)
find_package(X11 COMPONENTS ICE SM Xcursor Xext Xfixes Xi Xinerama Xrandr Xrender X11)
set_package_properties(X11 PROPERTIES
PURPOSE "Required for X11/X.Org integration support"
DESCRIPTION "Open source implementation of the X Window System"
URL "http://www.x.org"
TYPE REQUIRED
)
find_package(Fontconfig)
set_package_properties(Fontconfig PROPERTIES
PURPOSE "Required for fonts configuration support"
DESCRIPTION "Library for configuring and customizing font access"
URL "http://www.freedesktop.org/wiki/Software/fontconfig/"
TYPE REQUIRED
)
find_package(Freetype)
set_package_properties(Freetype PROPERTIES
PURPOSE "Required for fonts configuration support"
DESCRIPTION "Freely available software library to render fonts"
URL "http://www.freetype.org"
TYPE REQUIRED
)
endif()
if(WITH_OPENGL)
find_package(OpenGL)
set_package_properties(OpenGL PROPERTIES
PURPOSE "Required for OpenGL support"
DESCRIPTION "The Mesa 3D Graphics Library"
URL "http://www.mesa3d.org/"
TYPE REQUIRED
)
endif()
if(WITH_MULTIMEDIA)
find_package(GStreamer)
set_package_properties(GStreamer PROPERTIES
PURPOSE "Required for multimedia support"
DESCRIPTION "Open source multimedia framework"
URL "http://gstreamer.freedesktop.org"
TYPE REQUIRED
)
endif()
if(WITH_WEBKIT)
find_package(LibXml2)
set_package_properties(LibXml2 PROPERTIES
PURPOSE "Required for XML support in WebKit"
DESCRIPTION "XML C parser and toolkit developed for the Gnome project"
URL "http://www.xmlsoft.org/"
TYPE REQUIRED
)
endif()
endif()
if(WIN32)
add_definitions(-DUNICODE)
endif()
if(NOT CUPS_FOUND)
add_definitions(-DQT_NO_CUPS)
endif()
if(NOT GLIB2_FOUND)
add_definitions(-DQT_NO_GLIB)
endif()
if(NOT FREETYPE_FOUND)
add_definitions(-DQT_NO_FREETYPE)
endif()
if(NOT ZLIB_FOUND)
include_directories(${CMAKE_SOURCE_DIR}/src/3rdparty/zlib)
endif()
if(HAVE_LARGEFILESUPPORT)
if(_FILE_OFFSET_BITS)
add_definitions(-D_FILE_OFFSET_BITS=64)
endif()
if(_LARGE_FILES)
add_definitions(-D_LARGE_FILES)
endif()
if(_LARGEFILE_SOURCE)
add_definitions(-D_LARGEFILE_SOURCE)
endif()
endif()
configure_file(
${CMAKE_SOURCE_DIR}/cmake/qt-acconfig.h.cmake
${CMAKE_BINARY_DIR}/include/qt-acconfig.h
)
configure_file(
${CMAKE_SOURCE_DIR}/src/core/global/cs_build_info.h.in
${CMAKE_BINARY_DIR}/include/QtCore/cs_build_info.h
)
# file locations for building
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# The Ninja generator does not yet know how to build archives in pieces, and so response
# files must be used to deal with very long linker command lines.
# See https://bugs.webkit.org/show_bug.cgi?id=129771
set(CMAKE_NINJA_FORCE_RESPONSE_FILE 1)
# check components dependencies
# TODO: revisit once _OPTIONAL_COMPONENTS has changed
if(WITH_MULTIMEDIA AND NOT WITH_GUI)
message(SEND_ERROR "Multimedia component requires Gui component")
elseif(WITH_PHONON AND NOT (WITH_GUI AND WITH_NETWORK))
message(SEND_ERROR "Phonon component requires Gui and Network components")
elseif(WITH_OPENGL AND NOT WITH_GUI)
message(SEND_ERROR "OpenGL component requires Gui component")
elseif(WITH_SVG AND NOT WITH_GUI)
message(SEND_ERROR "Svg component requires Gui component")
elseif(WITH_XMLPATTERNS AND NOT WITH_NETWORK)
message(SEND_ERROR "XmlPatterns component requires Network component")
elseif(WITH_WEBKIT AND NOT (WITH_GUI AND WITH_NETWORK AND WITH_SCRIPT))
message(SEND_ERROR "WebKit component requires Gui, Network and Script components")
endif()
add_subdirectory(src/core)
foreach(component ${_OPTIONAL_COMPONENTS})
string(TOUPPER ${component} uppercomp)
if(WITH_${uppercomp})
string(TOLOWER ${component} lowercomp)
add_subdirectory(src/${lowercomp})
set(BUILD_COMPONENTS "${BUILD_COMPONENTS} ${component}")
endif()
endforeach()
if(WITH_XML)
add_subdirectory(src/tools/shared)
add_subdirectory(src/tools/lconvert)
add_subdirectory(src/tools/lrelease)
add_subdirectory(src/tools/lupdate)
endif()
if(WITH_XML AND WITH_GUI)
add_subdirectory(src/tools/rcc)
add_subdirectory(src/tools/uic)
endif()
configure_file(
${CMAKE_SOURCE_DIR}/cmake/CopperSpiceConfig.cmake
${CMAKE_BINARY_DIR}/CopperSpiceConfig.cmake
@ONLY
)
configure_file(
${CMAKE_SOURCE_DIR}/cmake/CopperSpiceConfigVersion.cmake
${CMAKE_BINARY_DIR}/CopperSpiceConfigVersion.cmake
@ONLY
)
install(
FILES
${CMAKE_BINARY_DIR}/CopperSpiceConfig.cmake
${CMAKE_BINARY_DIR}/CopperSpiceConfigVersion.cmake
${CMAKE_SOURCE_DIR}/cmake/CopperSpiceMacros.cmake
${CMAKE_SOURCE_DIR}/cmake/InstallMinGW.cmake
DESTINATION cmake/CopperSpice
)
install(EXPORT CopperSpiceLibraryTargets
NAMESPACE CopperSpice::
FILE CopperSpiceLibraryTargets.cmake
DESTINATION cmake/CopperSpice
)
install(
EXPORT CopperSpiceBinaryTargets
NAMESPACE CopperSpice::
FILE CopperSpiceBinaryTargets.cmake
DESTINATION cmake/CopperSpice
)
message("")
message(STATUS "The following components will be built:")
message("\n * ${BUILD_COMPONENTS}\n")
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)