X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=CMakeLists.txt;h=686c96f3f216295783d33f726343c43d99ee3ad5;hp=a220522805838739749a7f45ddd58c19ac683525;hb=cd1a1f138ec3a0b1ade92e35e62d43913eb055d1;hpb=b0021c10835573ee881e067e9550a1625834177d diff --git a/CMakeLists.txt b/CMakeLists.txt index a2205228..686c96f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,13 +28,24 @@ 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) + +# General conveniences +set(CMAKE_AUTOMOC ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +# Moar stuff include(CheckFunctionExists) include(CheckIncludeFile) -include(CheckCXXCompilerFlag) -# 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 @@ -102,72 +113,6 @@ endif(LINK_EXTRA) # Build Types -if(CMAKE_CONFIGURATION_TYPES) - set(CMAKE_CONFIGURATION_TYPES Release RelWithDebInfo Debug Debugfull Profile MinSizeRel) - set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING - "Reset the configurations to what we need" - FORCE) -endif() - -if(NOT CMAKE_BUILD_TYPE) - SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING - "Choose the type of build, options are: None Debug Release RelWithDebInfo Debug Debugfull Profile MinSizeRel." - FORCE) -endif() - -# Qt debug flags -set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG QT_DEBUG) -set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUGFULL 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_PROFILE 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") # use CMake default -# set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O2") # use CMake default - set(CMAKE_CXX_FLAGS_DEBUG "-g -ggdb -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline") - set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3 -ggdb -fno-inline") - set(CMAKE_CXX_FLAGS_PROFILE "-g3 -ggdb -fno-inline -ftest-coverage -fprofile-arcs") - - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ansi -W -Wall -Wextra -Wnon-virtual-dtor -fno-strict-aliasing -Wundef -Wcast-align -Wpointer-arith -Wformat-security -fno-check-new -fno-common") - - check_cxx_compiler_flag(-Woverloaded-virtual CXX_W_OVERLOADED_VIRTUAL) - if(CXX_W_OVERLOADED_VIRTUAL) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual") - endif() - - # Just for miniz - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-function -Wno-undef -fno-strict-aliasing") -endif(CMAKE_COMPILER_IS_GNUCXX) - -# ... and for Clang -if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wextra -Wpointer-arith -Wformat-security -Woverloaded-virtual -fno-common -Werror=return-type") -# set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG -DQT_NO_DEBUG") # Use CMake default -# set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG -DQT_NO_DEBUG") # Use CMake default - set(CMAKE_CXX_FLAGS_DEBUG "-g -O2 -fno-inline") - set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3 -fno-inline") - set(CMAKE_CXX_FLAGS_PROFILE "-g3 -fno-inline -ftest-coverage -fprofile-arcs") - - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-function -Wno-undef -fno-strict-aliasing") -endif() - -# Mac build stuff -if(APPLE AND DEPLOY) - set(CMAKE_OSX_ARCHITECTURES "x86_64") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.6") - set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.6.sdk/") - add_definitions(-DMAC_10_6_SDK) -endif(APPLE AND DEPLOY) # Simplify checks if(WANT_MONO OR WANT_QTCLIENT) @@ -537,20 +482,18 @@ if(NOT WIN32) endif(HAVE_UMASK) endif(NOT WIN32) -# We need to create a version.gen -# For this, we create our genversion binary and make sure it is run every time. +# Generate version information from Git +include(GetGitRevisionDescription) +get_git_head_revision(GIT_REFSPEC GIT_HEAD) +git_describe(GIT_DESCRIBE --long) -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})