X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=CMakeLists.txt;h=686c96f3f216295783d33f726343c43d99ee3ad5;hp=4c6c1a558e88c22cab57691d62813295cd0f2116;hb=cd1a1f138ec3a0b1ade92e35e62d43913eb055d1;hpb=ff81aaec156b8dc2e12f49286fd69e55f215af29 diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c6c1a55..686c96f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,22 +25,27 @@ # NOTE: You should remove CMakeCache.txt if you plan to change any of these values! +cmake_minimum_required(VERSION 2.8.9) project(QuasselIRC) -include(CheckFunctionExists) -include(CheckIncludeFile) +# Versions +set(QUASSEL_MAJOR 0) +set(QUASSEL_MINOR 11) +set(QUASSEL_PATCH 0) +set(QUASSEL_VERSION_STRING "0.11-pre") -# cmake 2.6.2 is required for KDE >=4.2 and should be widespread enough now -# For building against Qt5, we check for an even newer cmake version below! -cmake_minimum_required(VERSION 2.6.2 FATAL_ERROR) +# Tell CMake about or own modules +set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) -if(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -endif(COMMAND cmake_policy) +# General conveniences +set(CMAKE_AUTOMOC ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +# Moar stuff +include(CheckFunctionExists) +include(CheckIncludeFile) -# Use our own (well, and KDE's) version of some modules -# In particular cmake's own FindQt4 and FindOpenSSL are quite buggy -set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules) +include(QuasselCompileSettings) include(QuasselMacros) # Various options and variables that can be set on the command line @@ -69,6 +74,10 @@ option(STATIC "Enable static building (might not be portable)" OFF) if(APPLE) option(DEPLOY "Mac OS X only! Adds required libs to bundle resources and create a dmg. Note: requires Qt to be built with 10.4u SDK" OFF) + # 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 "Enable OS X Notification Center support" ON) + endif(CMAKE_SYSTEM_VERSION VERSION_GREATER "11.9.9") endif(APPLE) # Default to embedding data in the static case @@ -102,51 +111,8 @@ if(LINK_EXTRA) link_libraries(${LINK_EXTRA}) endif(LINK_EXTRA) -# Build Type -# We need to make sure it's not empty -# Supported: Release, RelWithDebugInfo, Debug, Debugfull - -# On WIN32, only Release seems to work correctly (?) -if(WIN32) - set(DEFAULT_BUILD_TYPE "Release") -else(WIN32) - set(DEFAULT_BUILD_TYPE "RelWithDebugInfo") -endif(WIN32) +# Build Types -set(CMAKE_BUILD_TYPE ${DEFAULT_BUILD_TYPE} CACHE STRING "CMake Build Type") -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE ${DEFAULT_BUILD_TYPE} CACHE STRING "CMake Build Type" FORCE) -endif(NOT CMAKE_BUILD_TYPE) - -# Qt debug flags -set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG QT_DEBUG) -set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_FULLDEBUG QT_DEBUG) -set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE QT_NO_DEBUG NDEBUG) -set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO QT_NO_DEBUG NDEBUG) -set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL QT_NO_DEBUG NDEBUG) - -IF(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) - set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_DEBUG NDEBUG) -ENDIF() - -# Enable various flags on gcc -if(CMAKE_COMPILER_IS_GNUCXX) - # Let's just hope that all gccs support these options and skip the tests... - # -fno-strict-aliasing is needed apparently for Qt < 4.6 - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ansi -Wall -Wextra -Wnon-virtual-dtor -fno-strict-aliasing") - set(CMAKE_CXX_FLAGS_RELEASE "-O2 ${CMAKE_CXX_FLAGS}") - set(CMAKE_CXX_FLAGS_RELWITHDEBUGINFO "-g -O2 ${CMAKE_CXX_FLAGS}") - set(CMAKE_CXX_FLAGS_DEBUG "-g -ggdb -fno-reorder-blocks -fno-schedule-insns -fno-inline ${CMAKE_CXX_FLAGS}") - set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3 ${CMAKE_CXX_FLAGS_DEBUG}") -endif(CMAKE_COMPILER_IS_GNUCXX) - -# Mac build stuff -if(APPLE AND DEPLOY) - set(CMAKE_OSX_ARCHITECTURES "i386;ppc") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.4") - set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk/") - add_definitions(-DMAC_10_4_SDK) -endif(APPLE AND DEPLOY) # Simplify checks if(WANT_MONO OR WANT_QTCLIENT) @@ -187,6 +153,10 @@ if(WITH_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) + else(WITH_QT5) # Select a Qt installation here, if you don't want to use system Qt if(QT) @@ -195,10 +165,37 @@ else(WITH_QT5) endif(QT) # Now that we have the correct $PATH, lets find Qt! - find_package(Qt4 REQUIRED) + find_package(Qt4 ${QT_MIN_VERSION} REQUIRED) endif(WITH_QT5) +# 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) + get_filename_component(_lrelease_path ${QT_LRELEASE_EXECUTABLE} PATH) + if(WITH_QT5) + find_program(QT_LCONVERT_EXECUTABLE NAMES lconvert-qt5 lconvert PATHS ${_lrelease_path} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + else(WITH_QT5) + find_program(QT_LCONVERT_EXECUTABLE NAMES lconvert-qt4 lconvert PATHS ${_lrelease_path} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + endif(WITH_QT5) +endif(QT_LRELEASE_EXECUTABLE) + + +# 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() + + # Execinfo is needed for generating backtraces find_package(ExecInfo) if(EXECINFO_FOUND) @@ -291,15 +288,19 @@ if(BUILD_GUI) # Setup KDE4 support if(WITH_KDE AND NOT WITH_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} knotifyconfig) + 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) @@ -335,6 +336,13 @@ if(BUILD_GUI) 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 @@ -355,6 +363,14 @@ if(BUILD_GUI) set(INDICATEQT_LIBRARIES "") endif(WITH_LIBINDICATE AND NOT WITH_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 @@ -466,21 +482,18 @@ if(NOT WIN32) endif(HAVE_UMASK) endif(NOT WIN32) +# Generate version information from Git +include(GetGitRevisionDescription) +get_git_head_revision(GIT_REFSPEC GIT_HEAD) +git_describe(GIT_DESCRIBE --long) -# We need to create a version.gen -# For this, we create our genversion binary and make sure it is run every time. - -setup_qt_variables() -include_directories(${QUASSEL_QT_INCLUDES}) - -add_executable(genversion ${CMAKE_SOURCE_DIR}/src/common/genversion.cpp) -target_link_libraries(genversion ${QUASSEL_QT_LIBRARIES}) -set_target_properties(genversion PROPERTIES COMPILE_FLAGS "${QUASSEL_QT_COMPILEFLAGS}") +# Sanitize things if we're not in a Git repo +if(NOT GIT_HEAD OR NOT GIT_DESCRIBE) + set(GIT_HEAD "") + set(GIT_DESCRIBE "") +endif() -get_target_property(GENVERSION_EXECUTABLE genversion LOCATION) -add_custom_target(genversion_run ALL ${GENVERSION_EXECUTABLE} - ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/src/version.gen) -add_dependencies(genversion_run genversion) +configure_file(version.h.in ${CMAKE_BINARY_DIR}/version.h @ONLY) # These variables will be added to the main targets (CORE, QTCLIENT, MONO) set(COMMON_DEPS ${RC_WIN32})