From: Manuel Nickschas Date: Sun, 23 Mar 2014 01:39:38 +0000 (+0100) Subject: Completely rework the dependency handling in the build system X-Git-Tag: 0.11.0~92 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=2273a95ba9c277ce6dd7a67158a3d3ed9f161182;ds=sidebyside Completely rework the dependency handling in the build system Traditionally, optional build dependencies are handled in CMake via offering options and conditionally searching for the needed packages. This leads to having lots of options, boilerplate for telling the user which features are enabled or not, unclear handling of automagic dependencies, and so on. These days, CMake offers a much nicer way: feature_summary() and friends. To make use of this, one calls find_package unconditionally and then sets properties on the package that tell CMake if the dependency is optional or required, its purpose, a description of the package etc. At the end of configuration, CMake then displays a nice summary of all the packages searched for and (not) found, as well as other features. Quassel now makes use of this modern way of specifying dependencies, replacing most of the former options (they're still there, but unused now, and will be removed soon). Note that one can still disable an optional dependency Foo by passing -DCMAKE_DISABLE_FIND_PACKAGE_Foo=TRUE to CMake. I also took the opportunity to radically clean up and fix how we handle dependencies throughout the build system: * We no longer set an extra CMake variable to indicate that a package was found, but use the Foo_FOUND variable directly * Compile definitions and include directories are no longer set globally in the root CMakeLists.txt, but in the Quassel modules where they're actually needed; this should speed up compiling ever so slightly and generally make things much cleaner * Libraries are now linked directly to the Quassel modules that use them, rather than to the executable. This prepares us for making the modules shared libraries at some point, and is anyway The Right Thing™ to do * Fully support Qt5 in the build system, including finding the proper version of dependencies where appropriate and available Note that the changes to the build system are not complete yet, and some things may be broken now. Note also that while Qt5 is now supported in the build system, the code itself still requires many changes to actually compile with Qt5, so don't even try. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 76889d81..0ffb5291 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,14 +9,12 @@ cmake_minimum_required(VERSION 2.8.9) project(QuasselIRC) - # Versions set(QUASSEL_MAJOR 0) set(QUASSEL_MINOR 11) set(QUASSEL_PATCH 0) set(QUASSEL_VERSION_STRING "0.11-pre") - # Tell CMake about or own modules set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) @@ -24,7 +22,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) set(CMAKE_AUTOMOC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) - # Moar stuff include(CheckFunctionExists) include(CheckIncludeFile) @@ -33,12 +30,12 @@ include(QuasselCompileSettings) include(QuasselMacros) include(CMakeDependentOption) +include(FeatureSummary) # Options and variables that can be set on the command line ##################################################################### - # First, choose a Qt version. We support USE_QT4 and USE_QT5; if neither is set, prefer Qt4 for now option(USE_QT5 "Enable support for Qt5 (disables KDE integration)" OFF) if (USE_QT4) # takes precedence @@ -51,12 +48,17 @@ endif() # Select the binaries to build option(WANT_CORE "Build the core (server) binary" ON) -option(WANT_QTCLIENT "Build the Qt4 GUI client binary" ON) +option(WANT_QTCLIENT "Build the Qt GUI client binary" ON) option(WANT_MONO "Build the monolithic (all-in-one) binary" ON) +add_feature_info(WANT_CORE WANT_CORE "Build the core (server) binary") +add_feature_info(WANT_QTCLIENT WANT_QTCLIENT "Build the Qt GUI client binary") +add_feature_info(WANT_MONO WANT_MONO "Build the monolithic (all-in-one) binary") + # Whether to enable KDE integration (pulls in kdelibs and friends as a dependency); requires Qt4 for now cmake_dependent_option(WITH_KDE "KDE4 integration" OFF "USE_QT4" OFF) +add_feature_info(WITH_KDE WITH_KDE "Enable KDE4 integration") # Some options don't make sense with KDE cmake_dependent_option(WITH_PHONON "Phonon support (for audio notifications)" ON "NOT WITH_KDE" OFF) @@ -75,6 +77,7 @@ if (APPLE) # Notification Center is only available in > 10.8, which is Darwin v12 if (CMAKE_SYSTEM_VERSION VERSION_GREATER "11.9.9") option(WITH_NOTIFICATION_CENTER "OS X Notification Center support" ON) + add_feature_info(WITH_NOTIFICATION_CENTER WITH_NOTIFICATION_CENTER "Use the OS X Notification Center") endif() endif() @@ -106,6 +109,8 @@ endif() # Simplify later checks +##################################################################### + if (WANT_MONO OR WANT_QTCLIENT) set(BUILD_GUI true) endif() @@ -117,7 +122,6 @@ endif() # Set up Qt ##################################################################### - if (USE_QT5) message(STATUS "Building with the Qt5 libraries...") set(QT_MIN_VERSION "5.2.0") @@ -131,15 +135,14 @@ else() endif() endif() - if (USE_QT5) - find_package(Qt5Core ${QT_MIN_VERSION} REQUIRED) - # We need QtWidgets - set(CLIENT_QT_MODULES ${CLIENT_QT_MODULES} Widgets) - - # Setup the i18n-related variables - find_package(Qt5LinguistTools) + find_package(Qt5Core ${QT_MIN_VERSION} QUIET REQUIRED) + # Contains lconvert and friends + find_package(Qt5LinguistTools QUIET) + set_package_properties(Qt5LinguistTools PROPERTIES TYPE RECOMMENDED + PURPOSE "Required for localization support" + ) else() # Select a Qt installation here, if you don't want to use system Qt if(QT_PATH) @@ -148,10 +151,9 @@ else() endif() # Now that we have the correct $PATH, lets find Qt! - find_package(Qt4 ${QT_MIN_VERSION} REQUIRED) + find_package(Qt4 ${QT_MIN_VERSION} QUIET REQUIRED) endif() - # Neither Qt4 nor Qt5 consider lconvert relevant, so they don't support finding it... # Rather than shipping hacked buildsys files, let's just infer the path from lrelease if (QT_LRELEASE_EXECUTABLE) @@ -163,42 +165,145 @@ if (QT_LRELEASE_EXECUTABLE) endif() endif() +add_feature_info("Qt Linguist Tools" QT_LRELEASE_EXECUTABLE "Translation support for Quassel") -# Dependencies +# Optional Dependencies +# +# Note that you can forcefully disable optional packages +# using -DCMAKE_DISABLE_FIND_PACKAGE_=TRUE ##################################################################### -# zlib for compression, however we can always fall back to miniz -find_package(ZLIB) -if(ZLIB_FOUND) - message(STATUS "Using system zlib for compression") - add_definitions(-DHAVE_ZLIB) - include_directories(${ZLIB_INCLUDE_DIRS}) - set(COMMON_LIBRARIES ${COMMON_LIBRARIES} ${ZLIB_LIBRARIES}) -else() - message(STATUS "zlib NOT found, using bundled miniz for compression") - if(${CMAKE_SIZEOF_VOID_P} EQUAL 4) - message(STATUS "WARNING: This may be slow on 32 bit systems!") - endif() -endif() - +if(USE_QT5) + if (BUILD_GUI) + find_package(Qt5DBus QUIET) + set_package_properties(Qt5DBus PROPERTIES TYPE RECOMMENDED + URL "http://qt.digia.com" + DESCRIPTION "D-Bus support for Qt5" + PURPOSE "Needed for supporting D-Bus-based notifications and tray icon, used by most modern desktop environments" + ) + if (Qt5DBus_FOUND) + find_package(dbusmenu-qt5 QUIET) + set_package_properties(dbusmenu-qt5 PROPERTIES TYPE RECOMMENDED + URL "https://launchpad.net/libdbusmenu-qt" + DESCRIPTION "a library implementing the DBusMenu specification" + PURPOSE "Required for having a context menu for the D-Bus-based tray icon" + ) + endif() + + find_package(Phonon4Qt5 QUIET) + set_package_properties(Phonon4Qt5 PROPERTIES TYPE RECOMMENDED + URL "https://projects.kde.org/projects/kdesupport/phonon" + DESCRIPTION "a multimedia abstraction library" + PURPOSE "Required for audio notifications" + ) + + if (WITH_WEBKIT) + find_package(Qt5Webkit QUIET) + set_package_properties(Qt5Webkit PROPERTIES TYPE RECOMMENDED + URL "http://qt.digia.com" + DESCRIPTION "a Webkit implementation for Qt" + PURPOSE "Needed for displaying previews for URLs in chat" + ) + endif() + add_feature_info("WITH_WEBKIT and QtWebkit module" Qt5Webkit_FOUND "Support showing previews for URLs in chat") + + endif(BUILD_GUI) + if (BUILD_CORE) + # While QCA2 seems to support Qt5, it is not actually co-installable or distinguishable from the Qt4 version... + # In order to avoid linking against the Qt4 version (which is probably the one installed), disable this for now + #find_package(QCA2 QUIET) + #set_package_properties(QCA2 PROPERTIES TYPE RECOMMENDED + # URL "https://projects.kde.org/projects/kdesupport/qca" + # DESCRIPTION "Qt Cryptographic Architecture" + # PURPOSE "Required for encryption support" + #) + + endif(BUILD_CORE) + +else(USE_QT5) + if (BUILD_GUI) + add_feature_info("QtDBus module" QT_QTDBUS_FOUND "Needed for supporting D-Bus-based notifications and tray icon, used by most modern desktop environments") + if (QT_QTDBUS_FOUND) + find_package(libdbusmenu-qt QUIET) + set_package_properties(dbusmenu-qt PROPERTIES TYPE RECOMMENDED + URL "https://launchpad.net/libdbusmenu-qt" + DESCRIPTION "a library implementing the DBusMenu specification" + PURPOSE "Required for having a context menu for the D-Bus-based tray icon" + ) + endif() + + if (WITH_WEBKIT AND QT_QTWEBKIT_FOUND) + set(HAVE_WEBKIT true) + endif() + add_feature_info("WITH_WEBKIT and QtWebkit module" HAVE_WEBKIT "Support showing previews for URLs in chat") + + if (WITH_KDE) + # KDE has overzealous CFLAGS making miniz not compile, so save our old flags + set(_cflags ${CMAKE_C_FLAGS}) + find_package(KDE4 4.4 QUIET) + set_package_properties(KDE4 PROPERTIES TYPE REQUIRED + URL "http://www.kde.org" + DESCRIPTION "a world-class desktop environment" + PURPOSE "Enables various bits for improving integration with KDE" + ) + set(CMAKE_C_FLAGS ${_cflags}) + + else(WITH_KDE) + find_package(Phonon QUIET) + set_package_properties(Phonon PROPERTIES TYPE RECOMMENDED + URL "https://projects.kde.org/projects/kdesupport/phonon" + DESCRIPTION "a multimedia abstraction library" + PURPOSE "Required for audio notifications" + ) + + find_package(Libsnore QUIET) + set_package_properties(Libsnore PROPERTIES TYPE OPTIONAL + URL "https://github.com/TheOneRing/Snorenotify" + DESCRIPTION "a cross-platform notification framework" + PURPOSE "Enable support for the snorenotify framework" + ) + endif(WITH_KDE) + + find_package(IndicateQt QUIET) + set_package_properties(IndicateQt PROPERTIES TYPE OPTIONAL + URL "https://launchpad.net/libindicate-qt/" + DESCRIPTION "a library to raise flags on DBus for other components of the desktop to pick up and visualize" + PURPOSE "Provides integration into the Ayatana notification system used by e.g. Ubuntu" + ) + + endif(BUILD_GUI) + if (BUILD_CORE) + + find_package(QCA2 QUIET) + set_package_properties(QCA2 PROPERTIES TYPE RECOMMENDED + URL "https://projects.kde.org/projects/kdesupport/qca" + DESCRIPTION "Qt Cryptographic Architecture" + PURPOSE "Required for encryption support" + ) -# Execinfo is needed for generating backtraces -find_package(ExecInfo) -if(EXECINFO_FOUND) - add_definitions(-DHAVE_EXECINFO) - include_directories(${EXECINFO_INCLUDES}) - link_libraries(${EXECINFO_LIBRARIES}) -endif(EXECINFO_FOUND) + endif() +endif() -# PkgConfig isn't strictly required. -# However, some optional deps might not be found if it's not present, so warn! -find_package(PkgConfig) -if(NOT PKG_CONFIG_FOUND) - message(STATUS "WARNING: PkgConfig not available! Some dependencies for optional features might not be found.") - message(STATUS " Affected features might include encryption support, DBus menus and Ayatana notifications.") -endif(NOT PKG_CONFIG_FOUND) +# Non-Qt-based packages +# zlib for compression, however we can always fall back to miniz +find_package(ZLIB QUIET) +set_package_properties(ZLIB PROPERTIES TYPE RECOMMENDED + URL "http://www.zlib.net" + DESCRIPTION "a popular compression library" + PURPOSE "Use the most common library for protocol compression, instead of the bundled miniz implementation" +) + + +if (NOT WIN32) + # Execinfo is needed for generating backtraces + find_package(ExecInfo QUIET) + set_package_properties(ExecInfo PROPERTIES TYPE OPTIONAL + DESCRIPTION "a library for inspecting backtraces" + PURPOSE "Used for generating backtraces in case of a crash" + ) +endif() # Setup OpenSSL # We don't link to or include OpenSSL ourselves, but use exclusively the Qt API. @@ -217,167 +322,9 @@ else(WITH_OPENSSL) message(STATUS "Not enabling OpenSSL support") endif(WITH_OPENSSL) - -# Check for GUI specific stuff -if(BUILD_GUI) - - # Setup D-Bus support - if(WITH_DBUS) - if (USE_QT5) - find_package(Qt5DBus ${QT_MIN_VERSION}) - find_package(Qt5DBusTools) - endif() - - if(QT_QTDBUS_FOUND OR (Qt5DBus_FOUND AND Qt5DBusTools_FOUND)) - message(STATUS "Found QtDBus, enabling D-Bus support") - add_definitions(-DHAVE_DBUS) - set(HAVE_DBUS true) - set(CLIENT_QT_MODULES ${CLIENT_QT_MODULES} DBus) - - # check if we have dbusmenu as well - if (NOT USE_QT5) - find_package(DBusMenuQt) - if(DBUSMENUQT_FOUND) - message(STATUS "Enabling support for exporting the tray menu via D-Bus") - add_definitions(-DHAVE_DBUSMENU) - include_directories(${DBUSMENUQT_INCLUDE_DIR}) - set(CLIENT_LIBRARIES ${CLIENT_LIBRARIES} ${DBUSMENUQT_LIBRARIES}) - set(CLIENT_COMPILE_FLAGS "${CLIENT_COMPILE_FLAGS} ${DBUSMENUQT_DEFINITIONS}") - else(DBUSMENUQT_FOUND) - message(STATUS "Disabling support for exporting the tray menu via D-Bus") - endif(DBUSMENUQT_FOUND) - endif() - - else(QT_QTDBUS_FOUND OR (Qt5DBus_FOUND AND Qt5DBusTools_FOUND)) - message(STATUS "QtDBus not found, disabling D-Bus support") - endif(QT_QTDBUS_FOUND OR (Qt5DBus_FOUND AND Qt5DBusTools_FOUND)) - else(WITH_DBUS) - message(STATUS "Not enabling D-Bus support") - endif(WITH_DBUS) - - # Setup QtWebkit support - if(WITH_WEBKIT) - if (USE_QT5) - find_package(Qt5Webkit ${QT_MIN_VERSION} QUIET) - endif() - if(QT_QTWEBKIT_FOUND OR Qt5Webkit_FOUND) - message(STATUS "Found QtWebKit, enabling WebKit support") - add_definitions(-DHAVE_WEBKIT) - set(CLIENT_QT_MODULES ${CLIENT_QT_MODULES} Webkit XmlPatterns) - set(HAVE_WEBKIT true) - else(QT_QTWEBKIT_FOUND OR Qt5Webkit_FOUND) - message(STATUS "QtWebkit not found, disabling Webkit support") - endif(QT_QTWEBKIT_FOUND OR Qt5Webkit_FOUND) - else(WITH_WEBKIT) - message(STATUS "Not enabling Webkit support") - endif(WITH_WEBKIT) - - # Setup KDE4 support - if(WITH_KDE AND NOT USE_QT5) - # KDE has overzealous CFLAGS making miniz not compile, so save our old flags - set(_cflags ${CMAKE_C_FLAGS}) - find_package(KDE4) - if(KDE4_FOUND) - message(STATUS "Enabling KDE4 integration") - include_directories(${KDE4_INCLUDES}) - add_definitions(-DHAVE_KDE ${KDE4_DEFINITIONS}) - set(HAVE_KDE 1) - set(CLIENT_LIBRARIES ${CLIENT_LIBRARIES} ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBRARY} ${KDE4_SOLID_LIBS} ${KDE4_KNOTIFYCONFIG_LIBRARY}) - # We always use external icons for KDE4 support, since we use its iconloader rather than our own - set(EMBED_DATA OFF) - # Restore our old CFLAGS - set(CMAKE_C_FLAGS ${_cflags}) - else(KDE4_FOUND) - message(STATUS "KDE4 not found, disabling KDE integration") - endif(KDE4_FOUND) - else(WITH_KDE AND NOT USE_QT5) - message(STATUS "Not enabling KDE4 integration") - endif(WITH_KDE AND NOT USE_QT5) - - # Setup Phonon support - we only need this if we don't have or want KDE4 - if(NOT HAVE_KDE) - if(WITH_PHONON) - if(USE_QT5) - find_package(Qt5phonon) - if(Qt5phonon_FOUND) - message(STATUS "Enabling Phonon support") - add_definitions(-DHAVE_PHONON) - set(HAVE_PHONON true) - set(CLIENT_QT_MODULES ${CLIENT_QT_MODULES} phonon) - else(Qt5phonon_FOUND) - message(STATUS "Phonon not found, disabling audio notifications") - endif(Qt5phonon_FOUND) - else(USE_QT5) - find_package(Phonon) - if(PHONON_FOUND) - message(STATUS "Enabling Phonon support") - add_definitions(-DHAVE_PHONON) - include_directories(${PHONON_INCLUDES}) - set(CLIENT_LIBRARIES ${CLIENT_LIBRARIES} ${PHONON_LIBS}) - set(HAVE_PHONON true) - else(PHONON_FOUND) - message(STATUS "Phonon not found, disabling audio notifications") - endif(PHONON_FOUND) - endif(USE_QT5) - else(WITH_PHONON) - message(STATUS "Not enabling Phonon support") - endif(WITH_PHONON) - - find_package(Libsnore) - if(LIBSNORE_FOUND) - add_definitions(-DHAVE_LIBSNORE) - set(CLIENT_LIBRARIES ${CLIENT_LIBRARIES} ${LIBSNORE_LIBRARIES}) - set(HAVE_SNORENOTIFY true) - endif(LIBSNORE_FOUND) - endif(NOT HAVE_KDE) - - # Setup libindicate-qt support - if(WITH_LIBINDICATE AND NOT USE_QT5) - pkg_check_modules(INDICATEQT QUIET indicate-qt>=0.2.1) - if(INDICATEQT_FOUND) - message(STATUS "Enabling Ayatana notification support") - set(HAVE_INDICATEQT true) - add_definitions(-DHAVE_INDICATEQT) - link_directories(${INDICATEQT_LIBRARY_DIRS}) - set(CLIENT_LIBRARIES ${CLIENT_LIBRARIES} ${INDICATEQT_LIBRARIES}) - else(INDICATEQT_FOUND) - message(STATUS "Disabling Ayatana notification support") - endif(INDICATEQT_FOUND) - else(WITH_LIBINDICATE AND NOT USE_QT5) - message(STATUS "Not enabling Ayatana notification support") - # We don't want to link against it even if another package has found it - set(INDICATEQT_LIBRARIES "") - endif(WITH_LIBINDICATE AND NOT USE_QT5) - - # Setup OS X notification center support - if(WITH_NOTIFICATION_CENTER AND APPLE) - set(HAVE_NOTIFICATION_CENTER true) - add_definitions(-DHAVE_NOTIFICATION_CENTER) - set(CLIENT_LIBRARIES ${CLIENT_LIBRARIES} - /System/Library/Frameworks/Foundation.framework - ) - endif() -endif(BUILD_GUI) - # Core-only deps if(BUILD_CORE) - # Setup encryption support - if(WITH_CRYPT AND NOT USE_QT5) - find_package(QCA2) - if(QCA2_FOUND) - message(STATUS "Enabling encryption support") - add_definitions(-DHAVE_QCA2) - set(LINK_QCA2 QCA2) - set(HAVE_QCA2 true) - set(MOC_DEFINES ${MOC_DEFINES} -DHAVE_QCA2) - else(QCA2_FOUND) - message(STATUS "Disabling encryption support") - endif(QCA2_FOUND) - else(WITH_CRYPT AND NOT USE_QT5) - message(STATUS "Not enabling encryption support") - endif(WITH_CRYPT AND NOT USE_QT5) - # Setup syslog support if(WITH_SYSLOG) check_include_file(syslog.h HAVE_SYSLOG_H) @@ -395,19 +342,38 @@ if(BUILD_CORE) endif(BUILD_CORE) +# +##################################################################### + +if (NOT ZLIB_FOUND) + message(STATUS "zlib NOT found, using bundled miniz for compression") + if (${CMAKE_SIZEOF_VOID_P} EQUAL 4) + message(STATUS "WARNING: This may be slow on 32 bit systems!") + endif() +endif() + +if (KDE4_FOUND) + # We always use external icons for KDE4 support, since we use its iconloader rather than our own + set(EMBED_DATA OFF) + + # Better have the compile flags global, even for the core, to avoid problems with linking the mono client + add_definitions(-DHAVE_KDE ${KDE4_DEFINITIONS}) +endif() + + # Various settings ################## # needed to compile with mingw without kde -if(MINGW AND NOT HAVE_KDE) +if (MINGW AND NOT KDE4_FOUND) add_definitions(-D_WIN32_WINNT=0x0500) message(STATUS "Added _WIN32_WINNT=0x0500 definition for MinGW") # workaround for bug in mingw gcc 4.0 add_definitions(-U__STRICT_ANSI__) -endif(MINGW AND NOT HAVE_KDE) +endif() # Now set up install locations; those are set by KDE if integration is enabled -if(NOT HAVE_KDE) +if(NOT KDE4_FOUND) if(WIN32) set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX} CACHE FILEPATH "Install path for binaries") set(DATA_INSTALL_DIR $ENV{APPDATA}/quassel-irc.org/share/apps CACHE FILEPATH "Install path for data files") @@ -419,7 +385,7 @@ if(NOT HAVE_KDE) set(ICON_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/icons CACHE FILEPATH "Global icon install path") set(XDG_APPS_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/applications CACHE FILEPATH "Install path for .desktop files") endif(WIN32) -endif(NOT HAVE_KDE) +endif() if(EMBED_DATA) message(STATUS "Embedding data files into the binary") @@ -457,9 +423,9 @@ if(WIN32) endif(HAVE_SSL AND STATIC) endif(WIN32) -if(HAVE_INDICATEQT) +if(INDICATEQT_FOUND) add_definitions(-DXDG_APPS_INSTALL_DIR=${XDG_APPS_INSTALL_DIR}) -endif(HAVE_INDICATEQT) +endif() if(NOT WIN32) check_function_exists(umask HAVE_UMASK) @@ -492,3 +458,11 @@ add_subdirectory(icons) add_subdirectory(pics) add_subdirectory(po) add_subdirectory(src) + +# Set up and display feature summary +##################################################################### + +feature_summary(WHAT ALL + INCLUDE_QUIET_PACKAGES + FATAL_ON_MISSING_REQUIRED_PACKAGES +) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5a841956..5a7f9f70 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -44,14 +44,18 @@ if(WANT_CORE) install(TARGETS quasselcore RUNTIME DESTINATION ${BIN_INSTALL_DIR}) endif(WANT_CORE) +if (KDE4_FOUND) + include_directories(${KDE4_INCLUDES}) +endif() + if(WANT_QTCLIENT) add_executable(quasselclient WIN32 common/main.cpp ${COMMON_DEPS} ${CLIENT_DEPS}) qt_use_modules(quasselclient Core Gui Network ${CLIENT_QT_MODULES} ${MAIN}) add_dependencies(quasselclient po) set_target_properties(quasselclient PROPERTIES - COMPILE_FLAGS "-DBUILD_QTUI ${CLIENT_COMPILE_FLAGS}" + COMPILE_FLAGS "-DBUILD_QTUI" OUTPUT_NAME ../quasselclient) - target_link_libraries(quasselclient ${LINK_KDE} mod_qtui mod_uisupport mod_client mod_common ${COMMON_LIBRARIES} ${CLIENT_LIBRARIES} ${QUASSEL_SSL_LIBRARIES}) + target_link_libraries(quasselclient mod_qtui mod_uisupport mod_client mod_common ${COMMON_LIBRARIES} ${CLIENT_LIBRARIES} ${QUASSEL_SSL_LIBRARIES}) install(TARGETS quasselclient RUNTIME DESTINATION ${BIN_INSTALL_DIR}) endif(WANT_QTCLIENT) @@ -60,7 +64,7 @@ if(WANT_MONO) qt_use_modules(quassel Core Gui Network ${CLIENT_QT_MODULES} ${CORE_QT_MODULES} ${MAIN}) add_dependencies(quassel po) set_target_properties(quassel PROPERTIES - COMPILE_FLAGS "-DBUILD_MONO ${CLIENT_COMPILE_FLAGS}" + COMPILE_FLAGS "-DBUILD_MONO" OUTPUT_NAME ../quassel) target_link_libraries(quassel mod_qtui mod_uisupport mod_client mod_core mod_common ${COMMON_LIBRARIES} ${CLIENT_LIBRARIES} ${QUASSEL_SSL_LIBRARIES}) install(TARGETS quassel RUNTIME DESTINATION ${BIN_INSTALL_DIR}) diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index 935ba862..bc74ecce 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -38,14 +38,20 @@ set(SOURCES clientcoreinfo.h ) -if (USE_QT5) - list(APPEND qt_modules Widgets) +if (KDE4_FOUND) + include_directories(${KDE4_INCLUDES}) + add_definitions(-DHAVE_KDE ${KDE4_DEFINITIONS}) endif() -if (HAVE_DBUS) - list(APPEND qt_modules DBus) +if (USE_QT5) + list(APPEND qt_modules Widgets) endif() add_library(mod_client STATIC ${SOURCES}) qt_use_modules(mod_client Network Core Gui ${qt_modules}) + +if (KDE4_FOUND) + target_link_libraries(mod_client ${KDE4_SOLID_LIBS}) +endif() + add_dependencies(mod_client mod_common) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 0191c811..b2f9c71a 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -46,11 +46,14 @@ set(SOURCES ) -if (HAVE_QCA2) +if (QCA2_FOUND) set(SOURCES ${SOURCES} keyevent.cpp) -endif(HAVE_QCA2) +endif() -if (NOT ZLIB_FOUND) +if (ZLIB_FOUND) + add_definitions(-DHAVE_ZLIB) + include_directories(${ZLIB_INCLUDE_DIRS}) +else() set(SOURCES ${SOURCES} ../../3rdparty/miniz/miniz.c) endif() @@ -60,7 +63,11 @@ endif(APPLE) if (WIN32) set(SOURCES ${SOURCES} logbacktrace_win.cpp) -elseif (UNIX) +else() + if (EXECINFO_FOUND) + add_definitions(-DHAVE_EXECINFO) + include_directories(${EXECINFO_INCLUDES}) + endif() set(SOURCES ${SOURCES} logbacktrace_unix.cpp) endif() @@ -71,4 +78,4 @@ if(APPLE) target_link_libraries(mod_common "-framework CoreServices" "-framework CoreFoundation") endif(APPLE) -target_link_libraries(mod_common ${CMAKE_DL_LIBS}) +target_link_libraries(mod_common ${CMAKE_DL_LIBS} ${EXECINFO_LIBRARIES} ${ZLIB_LIBRARIES}) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 25e14884..e3372355 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -40,15 +40,19 @@ set(SOURCES coreeventmanager.h ) +set(LIBS ) + if(HAVE_SSL) set(SOURCES ${SOURCES} sslserver.cpp) include_directories(${OPENSSL_INCLUDE_DIR}) endif(HAVE_SSL) -if(HAVE_QCA2) - set(SOURCES ${SOURCES} cipher.cpp) - include_directories(${QCA2_INCLUDE_DIR}) -endif(HAVE_QCA2) +if (QCA2_FOUND) + add_definitions(-DHAVE_QCA2) + include_directories(${QCA2_INCLUDE_DIR}) + list(APPEND SOURCES cipher.cpp) + list(APPEND LIBS ${QCA2_LIBRARIES}) +endif() include_directories(${CMAKE_SOURCE_DIR}/src/common) @@ -59,6 +63,6 @@ qt_use_modules(mod_core Core Network Script Sql) add_dependencies(mod_core mod_common) -if(HAVE_QCA2) - target_link_libraries(mod_core ${QCA2_LIBRARIES}) -endif(HAVE_QCA2) +if (LIBS) + target_link_libraries(mod_core ${LIBS}) +endif() diff --git a/src/qtui/CMakeLists.txt b/src/qtui/CMakeLists.txt index c2c747bb..cb040e06 100644 --- a/src/qtui/CMakeLists.txt +++ b/src/qtui/CMakeLists.txt @@ -75,42 +75,72 @@ set(FORMS settingspagedlg.ui simplenetworkeditor.ui receivefiledlg.ui - topicwidget.ui) - -if(HAVE_KDE) - set(SOURCES ${SOURCES} knotificationbackend.cpp) -else(HAVE_KDE) - if(HAVE_SNORENOTIFY) - set(SOURCES ${SOURCES} snorenotificationbackend.cpp) - set(FORMS ${FORMS} snorentificationconfigwidget.ui) - endif(HAVE_SNORENOTIFY) - if(HAVE_PHONON) - set(SOURCES ${SOURCES} phononnotificationbackend.cpp) - set(FORMS ${FORMS} phononnotificationconfigwidget.ui) + topicwidget.ui +) + +set(LIBS ) +set(QT_MODULES ) + +if (KDE4_FOUND) + add_definitions(-DHAVE_KDE ${KDE4_DEFINITIONS}) + include_directories(${KDE4_INCLUDES}) + list(APPEND SOURCES knotificationbackend.cpp) + list(APPEND LIBS ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBRARY} ${KDE4_KNOTIFYCONFIG_LIBRARY}) +endif() + +if (LIBSNORE_FOUND) + add_definitions(-DHAVE_SNORENOTIFY) + include_directories(${LIBSNORE_INCLUDE_DIRS}) + list(APPEND SOURCES snorenotificationbackend.cpp) + list(APPEND FORMS snorentificationconfigwidget.ui) + list(APPEND LIBS ${LIBSNORE_LIBRARIES}) +endif() + +if (PHONON_FOUND OR Phonon4Qt5_FOUND) + add_definitions(-DHAVE_PHONON) include_directories(${PHONON_INCLUDES}) - endif(HAVE_PHONON) -endif(HAVE_KDE) + set(SOURCES ${SOURCES} phononnotificationbackend.cpp) + set(FORMS ${FORMS} phononnotificationconfigwidget.ui) + list(APPEND LIBS ${PHONON_LIBS}) # PHONON_LIBRARIES only exists in config mode, it's not set by the legacy FindPhonon.cmake +endif() + +if (QT_QTDBUS_FOUND OR Qt5DBus_FOUND) + add_definitions(-DHAVE_DBUS) + list(APPEND QT_MODULES DBus) + if (dbusmenu-qt_FOUND OR dbusmenu-qt5_FOUND) + add_definitions(-DHAVE_DBUSMENU) + include_directories(${dbusmenu-qt_INCLUDE_DIRS} ${dbusmenu-qt5_INCLUDE_DIRS}) + list(APPEND LIBS ${dbusmenu-qt_LIBRARIES} ${dbusmenu-qt5_LIBRARIES}) + endif() + + list(APPEND SOURCES statusnotifieritem.cpp statusnotifieritemdbus.cpp dockmanagernotificationbackend.cpp) + qt_add_dbus_interface(SOURCES ../../interfaces/org.kde.StatusNotifierWatcher.xml statusnotifierwatcher) + qt_add_dbus_interface(SOURCES ../../interfaces/org.freedesktop.Notifications.xml notificationsclient) + qt_add_dbus_adaptor (SOURCES ../../interfaces/org.kde.StatusNotifierItem.xml statusnotifieritemdbus.h StatusNotifierItemDBus) +endif() -if (HAVE_DBUS) - set(SOURCES ${SOURCES} statusnotifieritem.cpp statusnotifieritemdbus.cpp dockmanagernotificationbackend.cpp) - qt_add_dbus_interface(DBUS ../../interfaces/org.kde.StatusNotifierWatcher.xml statusnotifierwatcher) - qt_add_dbus_interface(DBUS ../../interfaces/org.freedesktop.Notifications.xml notificationsclient) - qt_add_dbus_adaptor(DBUS ../../interfaces/org.kde.StatusNotifierItem.xml statusnotifieritemdbus.h StatusNotifierItemDBus) -endif(HAVE_DBUS) +if (QT_QTWEBKIT_FOUND OR Qt5Webkit_FOUND) + add_definitions(-DHAVE_WEBKIT) + list(APPEND QT_MODULES Webkit XmlPatterns) +endif() if(HAVE_SSL) set(SOURCES ${SOURCES} sslinfodlg.cpp) set(FORMS ${FORMS} sslinfodlg.ui) endif(HAVE_SSL) -if(INDICATEQT_FOUND) - set(SOURCES ${SOURCES} indicatornotificationbackend.cpp) - set(FORMS ${FORMS} indicatornotificationconfigwidget.ui) - include_directories(${INDICATEQT_INCLUDE_DIRS}) -endif(INDICATEQT_FOUND) +if (INDICATEQT_FOUND) + add_definitions(-DHAVE_INDICATEQT) + include_directories(${INDICATEQT_INCLUDE_DIRS}) + list(APPEND SOURCES indicatornotificationbackend.cpp) + list(APPEND FORMS indicatornotificationconfigwidget.ui) + list(APPEND LIBS ${INDICATEQT_LIBRARIES}) +endif() -if(HAVE_NOTIFICATION_CENTER) - set(SOURCES ${SOURCES} osxnotificationbackend.mm) +if (WITH_NOTIFICATION_CENTER) + add_definitions(-DHAVE_NOTIFICATION_CENTER) + list(APPEND SOURCES osxnotificationbackend.mm) + list(APPEND LIBS "/System/Library/Frameworks/Foundation.framework") endif() foreach(FORM ${FORMS}) @@ -141,18 +171,15 @@ include_directories(${CMAKE_SOURCE_DIR}/src/common qt_wrap_ui(UI ${FORMPATH} ${SPFRM}) if (USE_QT5) - list(APPEND qt_modules Widgets) + list(APPEND QT_MODULES Widgets) endif() -if (HAVE_DBUS) - list(APPEND qt_modules DBus) -endif() -if (HAVE_WEBKIT) - list(APPEND qt_modules Webkit XmlPatterns) -endif() +add_library(mod_qtui STATIC ${SOURCES} ${SPSRC} ${UI}) +qt_use_modules(mod_qtui Core Gui Network ${QT_MODULES}) -add_library(mod_qtui STATIC ${SOURCES} ${SPSRC} ${DBUS} ${UI}) -qt_use_modules(mod_qtui Core Gui Network ${qt_modules}) +if (LIBS) + target_link_libraries(mod_qtui ${LIBS}) +endif() add_dependencies(mod_qtui mod_common mod_client mod_uisupport) diff --git a/src/qtui/settingspages/settingspages.cmake b/src/qtui/settingspages/settingspages.cmake index 5b7ca52d..ded24d7e 100644 --- a/src/qtui/settingspages/settingspages.cmake +++ b/src/qtui/settingspages/settingspages.cmake @@ -44,7 +44,7 @@ set(SP_FORMS servereditdlg.ui ) -if(NOT HAVE_KDE) - set(SETTINGSPAGES ${SETTINGSPAGES} shortcuts) - set(SP_SOURCES ${SP_SOURCES} keysequencewidget.cpp shortcutsmodel.cpp) -endif(NOT HAVE_KDE) +if (NOT KDE4_FOUND) + list(APPEND SETTINGSPAGES shortcuts) + list(APPEND SP_SOURCES keysequencewidget.cpp shortcutsmodel.cpp) +endif() diff --git a/src/uisupport/CMakeLists.txt b/src/uisupport/CMakeLists.txt index f60da429..8be2e95e 100644 --- a/src/uisupport/CMakeLists.txt +++ b/src/uisupport/CMakeLists.txt @@ -36,18 +36,16 @@ set(SOURCES abstractnotificationbackend.h ) -if(HAVE_KDE) +if (KDE4_FOUND) + include_directories(${KDE4_INCLUDES}) + add_definitions(-DHAVE_KDE ${KDE4_DEFINITIONS}) set(SOURCES ${SOURCES} kcmdlinewrapper.cpp) -endif(HAVE_KDE) +endif() include_directories(${CMAKE_SOURCE_DIR}/src/common ${CMAKE_SOURCE_DIR}/src/client ) -if(HAVE_QCA2) - include_directories(${QCA2_INCLUDE_DIR}) -endif(HAVE_QCA2) - if (USE_QT5) list(APPEND qt_modules Widgets) endif() @@ -55,4 +53,8 @@ endif() add_library(mod_uisupport STATIC ${SOURCES}) qt_use_modules(mod_uisupport Core Gui Network ${qt_modules}) +if (KDE4_FOUND) + target_link_libraries(mod_uisupport ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBRARY}) +endif() + add_dependencies(mod_uisupport mod_common mod_client)