cmake: Use official FindBacktrace rather than custom FindExecInfo
[quassel.git] / CMakeLists.txt
1 # Main CMake file for building Quassel IRC
2 #
3 # See INSTALL for possible CMake options (or read the code, Luke)
4 #####################################################################
5
6 # General setup
7 #####################################################################
8
9 cmake_minimum_required(VERSION 3.5)
10
11 # Versions
12 set(QUASSEL_MAJOR  0)
13 set(QUASSEL_MINOR 13)
14 set(QUASSEL_PATCH 50)
15 set(QUASSEL_VERSION_STRING "0.14-pre")
16
17 # Build type
18 if (CMAKE_CONFIGURATION_TYPES)
19     set(CMAKE_CONFIGURATION_TYPES Release RelWithDebInfo Debug Debugfull Profile)
20     set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "These are the configuration types we support" FORCE)
21 endif()
22
23 if(NOT CMAKE_BUILD_TYPE)
24     set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: Release RelWithDebInfo Debug Debugfull Profile None" FORCE)
25 endif()
26
27 # Output CMake and Quassel versions as well as build type for debug reasons
28 message(STATUS "Building Quassel ${QUASSEL_VERSION_STRING}...")
29 message(STATUS "Using CMake ${CMAKE_VERSION}")
30 message(STATUS "CMake build type: ${CMAKE_BUILD_TYPE}")
31
32 # Support ccache if found
33 # This should happen before calling project(), so compiler settings are validated.
34 option(USE_CCACHE "Enable support for ccache if available" ON)
35 if (USE_CCACHE)
36     message(STATUS "Checking for ccache")
37     find_program(CCACHE_PROGRAM ccache)
38     if (CCACHE_PROGRAM)
39         set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
40         message(STATUS "Checking for ccache - enabled")
41     else()
42         message(STATUS "Checking for ccache - not found")
43     endif()
44 endif()
45
46 # Set up project
47 project(Quassel CXX)
48
49 # General conveniences
50 set(CMAKE_AUTOMOC ON)
51 set(CMAKE_INCLUDE_CURRENT_DIR ON)
52
53 # Include various CMake modules
54 include(CMakePushCheckState)
55 include(CheckFunctionExists)
56 include(CheckIncludeFileCXX)
57 include(CheckCXXSourceCompiles)
58 include(CMakeDependentOption)
59 include(FeatureSummary)
60
61 # Tell CMake about or own modules
62 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
63 include(QuasselCompileSettings)
64 include(QuasselMacros)
65
66
67 # Options and variables that can be set on the command line
68 #####################################################################
69
70 # Select the binaries to build
71 option(WANT_CORE     "Build the core (server) binary"           ON)
72 option(WANT_QTCLIENT "Build the client-only binary"             ON)
73 option(WANT_MONO     "Build the monolithic (all-in-one) binary" ON)
74 add_feature_info(WANT_CORE WANT_CORE "Build the core (server) binary")
75 add_feature_info(WANT_QTCLIENT WANT_QTCLIENT "Build the client-only binary (requires a core to connect to)")
76 add_feature_info(WANT_MONO WANT_MONO "Build the monolithic (all-in-one) binary")
77
78 # Whether to enable integration with higher-tier KDE frameworks that require runtime support.
79 # We still optionally make use of certain Tier 1 frameworks even if WITH_KDE is disabled.
80 option(WITH_KDE "Integration with the KDE Frameworks runtime environment")
81 add_feature_info(WITH_KDE WITH_KDE "Integrate with the KDE Frameworks runtime environment")
82
83 # Icon theme support. By default, install the Breeze icon theme (may be disabled if a system installation is present)
84 option(WITH_BUNDLED_ICONS "Install required icons from the Breeze icon theme" ON)
85 add_feature_info(WITH_BUNDLED_ICONS WITH_BUNDLED_ICONS "Install required icons from the Breeze icon theme")
86
87 option(WITH_OXYGEN_ICONS "Support the Oxygen icon theme (KDE4)" OFF)
88 add_feature_info(WITH_OXYGEN_ICONS WITH_OXYGEN_ICONS "Support the Oxygen icon theme (KDE4)")
89
90 if (WITH_BUNDLED_ICONS)
91     add_definitions(-DWITH_BUNDLED_ICONS)
92 endif()
93 if (WITH_OXYGEN_ICONS)
94     add_definitions(-DWITH_OXYGEN_ICONS)
95 endif()
96
97 # For this, the feature info is added after we know if QtWebkit is installed
98 option(WITH_WEBKIT "WebKit support (for link previews) (legacy)" OFF)
99
100 # For this, the feature info is added after we know if QtWebEngine is installed
101 option(WITH_WEBENGINE "WebEngine support (for link previews)" ON)
102
103 if (APPLE)
104     # Notification Center is only available in > 10.8, which is Darwin v12
105     if (NOT CMAKE_SYSTEM_VERSION VERSION_LESS 12)
106         option(WITH_NOTIFICATION_CENTER "OS X Notification Center support" ON)
107         add_feature_info(WITH_NOTIFICATION_CENTER WITH_NOTIFICATION_CENTER "Use the OS X Notification Center")
108     endif()
109     find_library(CARBON_LIBRARY Carbon)
110     mark_as_advanced(CARBON_LIBRARY)
111     link_libraries(${CARBON_LIBRARY})
112 endif()
113
114 # Always embed on Windows, OSX or for a static build; never embed when enabling KDE integration
115 set(EMBED_DEFAULT OFF)
116 if (STATIC OR WIN32 OR APPLE)
117     set(EMBED_DEFAULT ON)
118 endif()
119 cmake_dependent_option(EMBED_DATA "Embed icons and translations into the binaries instead of installing them" ${EMBED_DEFAULT}
120                                    "NOT STATIC;NOT WIN32;NOT WITH_KDE" ${EMBED_DEFAULT})
121 if (NOT EMBED_DEFAULT)
122     add_feature_info(EMBED_DATA EMBED_DATA "Embed icons and translations in the binaries instead of installing them")
123 endif()
124
125 # The following options are not for end-user consumption, so don't list them in the feature summary
126 cmake_dependent_option(DEPLOY "Add required libs to bundle resources and create a dmg. Note: requires Qt to be built with 10.4u SDK" OFF "APPLE" OFF)
127
128 # Static builds are not supported and require some manual setup! Don't enable unless you know what you're doing (we don't know either)
129 cmake_dependent_option(STATIC      "Enable static building (not supported)" OFF "NOT WITH_KDE" OFF)
130
131 # For static builds, arbitrary extra libs might need to be linked
132 # Define a comma-separated list here
133 # e.g. for pgsql, we need -DLINK_EXTRA=pq;crypt
134 set(LINK_EXTRA "" CACHE STRING "Semicolon-separated list of libraries to be linked")
135 if (LINK_EXTRA)
136     string(REPLACE "," ";" LINK_EXTRA ${LINK_EXTRA})
137     link_libraries(${LINK_EXTRA})
138 endif()
139
140
141 # List of authenticators and the cmake flags to build them
142 # (currently that's just LDAP, but more can be added here).
143 ####################################################################
144 option(WITH_LDAP "Enable LDAP authentication support if present on system" ON)
145
146 # Setup CMake
147 #####################################################################
148
149 # Setting COMPILE_DEFINITIONS_<CONFIG> is deprecated since CMake 3.0 in favor of generator expressions.
150 # These have existed since CMake 2.8.10; until we depend on that, we have to explicitly enable the old policy.
151 if (POLICY CMP0043)
152     cmake_policy(SET CMP0043 OLD)
153 endif()
154
155 # Honor visibility settings for all target types
156 if (POLICY CMP0063)
157     cmake_policy(SET CMP0063 NEW)
158 endif()
159
160 # Don't automoc generated files
161 if (POLICY CMP0071)
162     cmake_policy(SET CMP0071 OLD)
163 endif()
164
165
166 # Simplify later checks
167 #####################################################################
168
169 if (WANT_MONO OR WANT_QTCLIENT)
170     set(BUILD_GUI true)
171 endif()
172 if (WANT_MONO OR WANT_CORE)
173     set(BUILD_CORE true)
174 endif()
175
176
177 # Set up Qt
178 #####################################################################
179
180 # Find package dependencies
181 #
182 # Note that you can forcefully disable optional packages
183 # using -DCMAKE_DISABLE_FIND_PACKAGE_<PkgName>=TRUE
184 #####################################################################
185
186 set(QT_MIN_VERSION "5.5.0")
187 add_definitions(-DHAVE_QT5)
188
189 find_package(Qt5Core ${QT_MIN_VERSION} QUIET)
190 set_package_properties(Qt5Core PROPERTIES TYPE REQUIRED
191     URL "https://www.qt.io/"
192     DESCRIPTION "contains core functionality for Qt"
193 )
194
195 # find_package without REQUIRED won't check for the version properly; also, older Qt5 versions
196 # used Qt5Core_VERSION_STRING... let's just make sure here that we bail out here if our Qt5 is not new enough.
197 if (NOT Qt5Core_VERSION OR Qt5Core_VERSION VERSION_LESS ${QT_MIN_VERSION})
198     message(FATAL_ERROR "Could NOT find Qt5 >= version ${QT_MIN_VERSION}!")
199 endif()
200
201 find_package(Qt5Network QUIET)
202 set_package_properties(Qt5Network PROPERTIES TYPE REQUIRED
203     DESCRIPTION "the network module for Qt5"
204 )
205
206 if (BUILD_GUI)
207     find_package(Qt5Gui QUIET)
208     set_package_properties(Qt5Gui PROPERTIES TYPE REQUIRED
209         DESCRIPTION "the GUI module for Qt5"
210     )
211     find_package(Qt5Widgets QUIET)
212     set_package_properties(Qt5Widgets PROPERTIES TYPE REQUIRED
213         DESCRIPTION "the widgets module for Qt5"
214     )
215
216     if (NOT WIN32)
217         find_package(Qt5DBus QUIET)
218         set_package_properties(Qt5DBus PROPERTIES TYPE RECOMMENDED
219             URL "https://www.qt.io/"
220             DESCRIPTION "D-Bus support for Qt5"
221             PURPOSE     "Needed for supporting D-Bus-based notifications and tray icon, used by most modern desktop environments"
222         )
223         if (Qt5DBus_FOUND)
224             find_package(dbusmenu-qt5 QUIET CONFIG)
225             set_package_properties(dbusmenu-qt5 PROPERTIES TYPE RECOMMENDED
226                 URL "https://launchpad.net/libdbusmenu-qt"
227                 DESCRIPTION "a library implementing the DBusMenu specification"
228                 PURPOSE     "Required for having a context menu for the D-Bus-based tray icon"
229             )
230         endif()
231     endif()
232
233     find_package(Qt5Multimedia QUIET)
234     set_package_properties(Qt5Multimedia PROPERTIES TYPE RECOMMENDED
235         URL "https://www.qt.io/"
236         DESCRIPTION "Multimedia support for Qt5"
237         PURPOSE     "Required for audio notifications"
238     )
239
240     find_package(LibsnoreQt5 0.7.0 QUIET)
241     set_package_properties(LibsnoreQt5 PROPERTIES TYPE OPTIONAL
242         URL "https://projects.kde.org/projects/playground/libs/snorenotify"
243         DESCRIPTION "a cross-platform notification framework"
244         PURPOSE     "Enable support for the snorenotify framework"
245     )
246     if(LibsnoreQt5_FOUND)
247         find_package(LibsnoreSettingsQt5)
248         set_package_properties(LibsnoreSettingsQt5 PROPERTIES TYPE REQUIRED
249             URL "https://projects.kde.org/projects/playground/libs/snorenotify"
250             DESCRIPTION "a cross-platform notification framework"
251             PURPOSE     "Enable support for the snorenotify framework"
252         )
253     endif()
254
255     if (WITH_WEBKIT)
256         find_package(Qt5WebKit QUIET)
257         set_package_properties(Qt5WebKit PROPERTIES TYPE RECOMMENDED
258             URL "https://www.qt.io/"
259             DESCRIPTION "a WebKit implementation for Qt"
260             PURPOSE     "Needed for displaying previews for URLs in chat"
261         )
262         if (Qt5WebKit_FOUND)
263             find_package(Qt5WebKitWidgets QUIET)
264             set_package_properties(Qt5WebKitWidgets PROPERTIES TYPE RECOMMENDED
265                 URL "https://www.qt.io/"
266                 DESCRIPTION "widgets for Qt's WebKit implementation"
267                 PURPOSE     "Needed for displaying previews for URLs in chat"
268             )
269         endif()
270     endif()
271
272     if (WITH_WEBKIT AND Qt5WebKitWidgets_FOUND)
273         set(HAVE_WEBKIT true)
274     endif()
275     add_feature_info("WITH_WEBKIT, QtWebKit and QtWebKitWidgets modules" HAVE_WEBKIT "Support showing previews for URLs in chat (legacy)")
276
277     if (WITH_WEBENGINE)
278         find_package(Qt5WebEngine QUIET)
279         set_package_properties(Qt5WebEngine PROPERTIES TYPE RECOMMENDED
280             URL "https://www.qt.io/"
281             DESCRIPTION "a WebEngine implementation for Qt"
282             PURPOSE     "Needed for displaying previews for URLs in chat"
283         )
284         if (Qt5WebEngine_FOUND)
285             find_package(Qt5WebEngineWidgets QUIET)
286             set_package_properties(Qt5WebEngineWidgets PROPERTIES TYPE RECOMMENDED
287                 URL "https://www.qt.io/"
288                 DESCRIPTION "widgets for Qt's WebEngine implementation"
289                 PURPOSE     "Needed for displaying previews for URLs in chat"
290             )
291         endif()
292     endif()
293
294     if (WITH_WEBENGINE AND Qt5WebEngineWidgets_FOUND)
295         set(HAVE_WEBENGINE true)
296     endif()
297     add_feature_info("WITH_WEBENGINE, QtWebEngine and QtWebEngineWidgets modules" HAVE_WEBENGINE "Support showing previews for URLs in chat")
298
299     # KDE Frameworks
300     ################
301
302     if (WITH_KDE)
303         set(ecm_find_type "REQUIRED")
304     else()
305         # Even with KDE integration disabled, we optionally use tier1 frameworks if we find them
306         set(ecm_find_type "RECOMMENDED")
307     endif()
308
309     # extra-cmake-modules
310     find_package(ECM NO_MODULE QUIET)
311     set_package_properties(ECM PROPERTIES TYPE ${ecm_find_type}
312         URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules"
313         DESCRIPTION "extra modules for CMake, maintained by the KDE project"
314         PURPOSE     "Required to find KDE Frameworks components"
315     )
316
317     if (ECM_FOUND)
318         list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
319         if (WITH_KDE)
320             find_package(KF5 COMPONENTS ConfigWidgets CoreAddons Notifications NotifyConfig Sonnet TextWidgets WidgetsAddons XmlGui QUIET)
321             set_package_properties(KF5 PROPERTIES TYPE REQUIRED
322                 URL "http://www.kde.org"
323                 DESCRIPTION "KDE Frameworks"
324                 PURPOSE     "Required for integration into the Plasma desktop"
325             )
326         else()
327             find_package(KF5Sonnet QUIET)
328             set_package_properties(KF5Sonnet PROPERTIES TYPE RECOMMENDED
329                 URL "http://api.kde.org/frameworks-api/frameworks5-apidocs/sonnet/html"
330                 DESCRIPTION "framework for providing spell-checking capabilities"
331                 PURPOSE "Enables spell-checking support in input widgets"
332             )
333         endif()
334     endif()
335
336 endif()
337
338 if (BUILD_CORE)
339     find_package(Qt5Script QUIET)
340     set_package_properties(Qt5Script PROPERTIES TYPE REQUIRED
341         DESCRIPTION "provides scripting support for Qt5"
342     )
343     find_package(Qt5Sql QUIET)
344     set_package_properties(Qt5Sql PROPERTIES TYPE REQUIRED
345         DESCRIPTION "the database support module for Qt5"
346     )
347
348     find_package(QCA2-QT5)
349     set_package_properties(QCA2-QT5 PROPERTIES TYPE RECOMMENDED
350         URL "https://projects.kde.org/projects/kdesupport/qca"
351         DESCRIPTION "Qt Cryptographic Architecture"
352         PURPOSE "Required for encryption support"
353     )
354
355 endif()
356
357 find_package(Qt5LinguistTools QUIET)
358 set_package_properties(Qt5LinguistTools PROPERTIES TYPE RECOMMENDED
359     DESCRIPTION "contains tools for handling translation files"
360     PURPOSE "Required for having translations"
361 )
362
363 # Some Qt5 versions do not define a target for lconvert, so we need to find it ourselves
364 if (Qt5LinguistTools_FOUND)
365     if (NOT TARGET Qt5::lconvert AND TARGET Qt5::lrelease)
366         get_target_property(_lrelease_location Qt5::lrelease LOCATION)
367         get_filename_component(_lrelease_path ${_lrelease_location} PATH)
368         find_program(QT_LCONVERT_EXECUTABLE NAMES lconvert-qt5 lconvert PATHS ${_lrelease_path} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
369     elseif(TARGET Qt5::lconvert AND NOT Qt5_LCONVERT_EXECUTABLE)
370         # Newer Qt5 versions define the target, but not the Qt5_LCONVERT_EXECUTABLE variable for some reason
371         get_target_property(QT_LCONVERT_EXECUTABLE Qt5::lconvert LOCATION)
372     endif()
373
374     # Compatibility with the Qt4 variables
375     set(QT_LRELEASE_EXECUTABLE ${Qt5_LRELEASE_EXECUTABLE})
376     set(QT_LUPDATE_EXECUTABLE ${Qt5_LUPDATE_EXECUTABLE})
377     if (Qt5_LCONVERT_EXECUTABLE)
378         set(QT_LCONVERT_EXECUTABLE ${Qt5_LCONVERT_EXECUTABLE})
379     endif()
380 endif()
381
382 # Non-Qt-based packages
383
384 find_package(ZLIB REQUIRED)
385 set_package_properties(ZLIB PROPERTIES TYPE REQUIRED
386     URL "http://www.zlib.net"
387     DESCRIPTION "a popular compression library"
388     PURPOSE     "Used for protocol compression"
389 )
390
391 if (NOT WIN32)
392     # Needed for generating backtraces
393     find_package(Backtrace QUIET)
394     set_package_properties(Backtrace PROPERTIES TYPE RECOMMENDED
395         DESCRIPTION "a header (and possibly library) for inspecting backtraces"
396         PURPOSE "Used for generating backtraces in case of a crash"
397     )
398 endif()
399
400 # Check for SSL support in Qt
401 # As there's no easy way to get Qt's configuration in particular for Qt5, let's just compile
402 # a small test program checking the defines. This works for both Qt4 and Qt5.
403 cmake_push_check_state(RESET)
404 set(CMAKE_REQUIRED_INCLUDES ${QT_INCLUDES} ${Qt5Core_INCLUDE_DIRS})
405 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
406
407 if (Qt5_POSITION_INDEPENDENT_CODE)
408     set(CMAKE_REQUIRED_FLAGS "-fPIC -DQT_NO_VERSION_TAGGING")
409 endif()
410
411 check_cxx_source_compiles("
412     #include \"qglobal.h\"
413     #if defined QT_NO_SSL
414     #  error \"No SSL support\"
415     #endif
416     int main() {}"
417     HAVE_SSL)
418 cmake_pop_check_state()
419
420 # Additional compile settings
421 #####################################################################
422
423 # This sets -fPIC and friends if required by the installed Qt5 library
424 if (Qt5_POSITION_INDEPENDENT_CODE)
425     set(CMAKE_POSITION_INDEPENDENT_CODE ON)
426     set(CMAKE_REQUIRED_FLAGS "-DQT_NO_VERSION_TAGGING")
427 endif()
428
429 # Needed to compile with mingw without kde
430 if (MINGW AND NOT WITH_KDE)
431     add_definitions(-D_WIN32_WINNT=0x0500)
432     message(STATUS "Added _WIN32_WINNT=0x0500 definition for MinGW")
433     # workaround for bug in mingw gcc 4.0
434     add_definitions(-U__STRICT_ANSI__)
435 endif()
436
437 # Sanitize compiler flags - old versions of KDE set -ansi, which breaks -std=c++11
438 if (CMAKE_COMPILER_IS_GNUCXX)
439     string(REPLACE "-ansi" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
440 endif()
441
442 # Setup LDAP Authentication support.
443 #####################################################################
444 if (WITH_LDAP)
445     find_package(Ldap)
446     if (LDAP_FOUND)
447         message(STATUS "Enabling LDAP authentication support")
448         set(HAVE_LDAP true)
449         add_definitions(-DHAVE_LDAP)
450     else()
451         message(STATUS "Disabling LDAP authentication support")
452     endif()
453 else()
454     message(STATUS "Not enabling LDAP authentication support")
455 endif()
456
457 # Setup support for KDE Frameworks
458 #####################################################################
459
460 # We want to do this up here, so we have the necessary variables and defines set before
461 # compiling anything
462
463 if (WITH_KDE)
464     # If KDE Frameworks are present, they're most probably providing Qt5 integration including icon loading
465     set(EMBED_DATA OFF)
466
467     include(KDEInstallDirs)
468     include(KDECompilerSettings)
469     include(KDECMakeSettings)
470
471     kde_enable_exceptions()
472     add_definitions(-DHAVE_KDE -DHAVE_KF5)
473     set(WITH_KF5 TRUE)
474 endif()
475
476 # This needs to come after setting up KDE integration, so we can use KDE-specific paths
477 include(QuasselInstallDirs)
478
479 # Various config-dependent checks and settings
480 #####################################################################
481
482 if (HAVE_SSL)
483     add_definitions(-DHAVE_SSL)
484 endif()
485 add_feature_info("SSL support in Qt" HAVE_SSL "Use secure network connections")
486
487 # Check for syslog support
488 if (NOT WIN32)
489     check_include_file_cxx(syslog.h HAVE_SYSLOG)
490     add_feature_info("syslog.h" HAVE_SYSLOG "Provide support for logging to the syslog")
491 endif()
492
493 add_feature_info("Qt Linguist Tools" QT_LCONVERT_EXECUTABLE "Translation support for Quassel")
494
495 if (EMBED_DATA)
496     message(STATUS "Embedding data files into the binary")
497 else()
498     message(STATUS "Installing data files separately")
499 endif()
500
501 if (NOT WIN32)
502     check_function_exists(umask HAVE_UMASK)
503     if(HAVE_UMASK)
504         add_definitions(-DHAVE_UMASK)
505     endif()
506 endif()
507
508
509 # Windows-specific stuff
510 #####################################################################
511
512 if (WIN32)
513     link_libraries(imm32 winmm dbghelp Secur32)  # missing by default :/
514     if (MSVC)
515         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DNOMINMAX")
516         set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBUGINFO "/debug /INCREMENTAL:YES /NODEFAULTLIB:libcmt /DEFAULTLIB:msvcrt")
517         set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:YES /NODEFAULTLIB:libcmt")
518         set(CMAKE_EXE_LINKER_FLAGS_DEBUGFULL "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
519         link_libraries(Version dwmapi shlwapi)
520         set(QT_QTMAIN_LIBRARY Qt5::WinMain)
521     endif()
522     if(HAVE_SSL AND STATIC)
523         find_package(OpenSSL REQUIRED)
524         link_libraries(${OPENSSL_LIBRARIES} ${OPENSSL_EAY_LIBRARIES})
525     endif()
526 endif()
527
528
529 # Static builds (very much non-portable, so don't use -DSTATIC
530 # unless you know what you do!)
531 #####################################################################
532
533 if(STATIC AND CMAKE_COMPILER_IS_GNUCXX)
534     set(CMAKE_CXX_FLAGS "-static-libgcc ${CMAKE_CXX_FLAGS}")
535     link_directories(${CMAKE_BINARY_DIR}/staticlibs) # override dynamic libs
536     if (HAVE_SSL)
537         set(QUASSEL_SSL_LIBRARIES ssl crypto)  # these miss in static builds
538     endif()
539 endif()
540
541
542 # Generate version information from Git
543 #####################################################################
544
545 include(GetGitRevisionDescription)
546 get_git_head_revision(GIT_REFSPEC GIT_HEAD)
547 git_describe(GIT_DESCRIBE --long)
548
549 # If in a Git repo we can get the commit-date from a git command
550 if (GIT_HEAD)
551     execute_process(
552         COMMAND git -c log.showsignature=false show -s --format=%ct
553         WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
554         OUTPUT_VARIABLE GIT_COMMIT_DATE
555         OUTPUT_STRIP_TRAILING_WHITESPACE
556     )
557 endif()
558
559 # If not in a Git repo try to read GIT_HEAD and GIT_DESCRIBE from
560 # enviroment
561 if (NOT GIT_HEAD OR NOT GIT_DESCRIBE)
562   if (DEFINED ENV{GIT_HEAD})
563       set(GIT_HEAD $ENV{GIT_HEAD})
564   endif()
565   if (DEFINED ENV{GIT_DESCRIBE})
566      set(GIT_DESCRIBE $ENV{GIT_DESCRIBE})
567   endif()
568 endif()
569
570 # Sanitize things if we're not in a Git repo
571 if (NOT GIT_HEAD OR NOT GIT_DESCRIBE)
572     set(GIT_HEAD "")
573     set(GIT_DESCRIBE "")
574     set(GIT_COMMIT_DATE 0)
575 endif()
576
577 configure_file(version.h.in ${CMAKE_BINARY_DIR}/version.h @ONLY)
578
579 # Prepare the build
580 #####################################################################
581
582 # These variables will be added to the main targets (CORE, QTCLIENT, MONO)
583 set(COMMON_DEPS ${RC_WIN32})
584 set(CORE_DEPS )
585 set(CLIENT_DEPS )
586
587 # Add needed subdirs - the order is important, since src needs some vars set by other dirs
588 add_subdirectory(data)
589 add_subdirectory(icons)
590 add_subdirectory(pics)
591 add_subdirectory(po)
592
593
594 # Set up and display feature summary
595 #####################################################################
596
597 feature_summary(WHAT ALL
598                 INCLUDE_QUIET_PACKAGES
599                 FATAL_ON_MISSING_REQUIRED_PACKAGES
600 )
601
602 # Finally, compile the sources
603 # We want this after displaying the feature summary to avoid ugly
604 # CMake backtraces in case a required Qt5 module is missing
605 #####################################################################
606
607 add_subdirectory(src)