diff options
Diffstat (limited to 'modules/FindKDE4Internal.cmake')
-rw-r--r-- | modules/FindKDE4Internal.cmake | 170 |
1 files changed, 94 insertions, 76 deletions
diff --git a/modules/FindKDE4Internal.cmake b/modules/FindKDE4Internal.cmake index 70ce60ac..f3a1d93c 100644 --- a/modules/FindKDE4Internal.cmake +++ b/modules/FindKDE4Internal.cmake @@ -216,6 +216,12 @@ # without going all over the place, but still produce better performance. # It's also important to note that gcc cannot detect all warning conditions # unless the optimiser is active. +# +# This module allows to depend on a particular minimum version of kdelibs. +# To acomplish that one should use the apropriate cmake syntax for +# find_package. For example to depend on kdelibs >= 4.1.0 one should use +# +# find_package(KDE4 4.1.0 REQUIRED) # _KDE4_PLATFORM_INCLUDE_DIRS is used only internally # _KDE4_PLATFORM_DEFINITIONS is used only internally @@ -228,26 +234,23 @@ # this is required now by cmake 2.6 and so must not be skipped by if(KDE4_FOUND) below -cmake_minimum_required(VERSION 2.4.5 FATAL_ERROR) - -# cmake 2.5, i.e. the cvs version between 2.4 and 2.6, is not supported -if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" STREQUAL "2.5") - message(FATAL_ERROR "You are using CMake 2.5, which was the unreleased development version between 2.4 and 2.6. This is no longer supported. Please update to CMake 2.6 or current cvs HEAD.") -endif("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" STREQUAL "2.5") +cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR) +# this second call will never fail +# it is here for the effect that it sets the cmake policies to the 2.4.x compatibility settings for now +cmake_minimum_required(VERSION 2.4.5) # CMake 2.6, set compatibility behaviour to cmake 2.4 # this must be executed always, because the CMAKE_MINIMUM_REQUIRED() command above # resets the policy settings, so we get a lot of warnings -if(COMMAND CMAKE_POLICY) - # CMP0000: don't require cmake_minimum_version() directly in the top level CMakeLists.txt, FindKDE4Internal.cmake is good enough - cmake_policy(SET CMP0000 OLD) - # CMP0002: in KDE4 we have multiple targets with the same name for the unit tests - cmake_policy(SET CMP0002 OLD) - # CMP0003: add the link paths to the link command as with cmake 2.4 - cmake_policy(SET CMP0003 OLD) - # CMP0005: keep escaping behaviour for definitions added via add_definitions() - cmake_policy(SET CMP0005 OLD) -endif(COMMAND CMAKE_POLICY) + +# CMP0000: don't require cmake_minimum_version() directly in the top level CMakeLists.txt, FindKDE4Internal.cmake is good enough +cmake_policy(SET CMP0000 OLD) +# CMP0002: in KDE4 we have multiple targets with the same name for the unit tests +cmake_policy(SET CMP0002 OLD) +# CMP0003: add the link paths to the link command as with cmake 2.4 +cmake_policy(SET CMP0003 OLD) +# CMP0005: keep escaping behaviour for definitions added via add_definitions() +cmake_policy(SET CMP0005 OLD) # Only do something if it hasn't been found yet @@ -262,17 +265,15 @@ find_package(Qt4 REQUIRED) # automoc4 (from kdesupport) is now required, Alex find_package(Automoc4 REQUIRED) -if (CMAKE_MAJOR_VERSION GREATER 4) - # cmake 2.6.0 and automoc4 0.9.83 didn't add the necessary definitions for backends to moc calls - if (NOT AUTOMOC4_VERSION) - # the version macro was added for 0.9.84 - set(AUTOMOC4_VERSION "0.9.83") - endif (NOT AUTOMOC4_VERSION) - macro_ensure_version("0.9.84" "${AUTOMOC4_VERSION}" _automoc4_version_ok) - if (NOT _automoc4_version_ok) - message(FATAL_ERROR "Your version of automoc4 is too old. You have ${AUTOMOC4_VERSION}, you need at least 0.9.84") - endif (NOT _automoc4_version_ok) -endif (CMAKE_MAJOR_VERSION GREATER 4) +# cmake 2.6.0 and automoc4 < 0.9.84 don't work right for -D flags +if (NOT AUTOMOC4_VERSION) + # the version macro was added for 0.9.84 + set(AUTOMOC4_VERSION "0.9.83") +endif (NOT AUTOMOC4_VERSION) +macro_ensure_version("0.9.84" "${AUTOMOC4_VERSION}" _automoc4_version_ok) +if (NOT _automoc4_version_ok) + message(FATAL_ERROR "Your version of automoc4 is too old. You have ${AUTOMOC4_VERSION}, you need at least 0.9.84") +endif (NOT _automoc4_version_ok) # use automoc4 from kdesupport set(KDE4_AUTOMOC_EXECUTABLE "${AUTOMOC4_EXECUTABLE}" ) @@ -357,7 +358,25 @@ else (_kdeBootStrapping) # we need at least this version: if (NOT KDE_MIN_VERSION) - set(KDE_MIN_VERSION "3.9.0") + if (KDE4_FIND_VERSION_MAJOR) + message("${KDE4_FIND_VERSION_MAJOR}") + if (${KDE4_FIND_VERSION_MAJOR} EQUAL 4) + if (KDE4_FIND_VERSION_MINOR) + set(KDE_MIN_VERSION "4.${KDE4_FIND_VERSION_MINOR}") + else (KDE4_FIND_VERSION_MINOR) + set(KDE_MIN_VERSION "4.0") + endif (KDE4_FIND_VERSION_MINOR) + if (KDE4_FIND_VERSION_PATCH) + set(KDE_MIN_VERSION "${KDE_MIN_VERSION}.${KDE4_FIND_VERSION_PATCH}") + else (KDE4_FIND_VERSION_PATCH) + set(KDE_MIN_VERSION "${KDE_MIN_VERSION}.0") + endif (KDE4_FIND_VERSION_PATCH) + else (${KDE4_FIND_VERSION_MAJOR} EQUAL 4) + message(FATAL_ERROR "FindKDE4 can only be used with KDE 4") + endif (${KDE4_FIND_VERSION_MAJOR} EQUAL 4) + else (KDE4_FIND_VERSION_MAJOR) + set (KDE_MIN_VERSION "4.0.0") + endif (KDE4_FIND_VERSION_MAJOR) endif (NOT KDE_MIN_VERSION) #message(STATUS "KDE_MIN_VERSION=${KDE_MIN_VERSION} found ${KDEVERSION}") @@ -506,25 +525,32 @@ option(KDE4_ENABLE_FINAL "Enable final all-in-one compilation") option(KDE4_BUILD_TESTS "Build the tests") option(KDE4_ENABLE_HTMLHANDBOOK "Create targets htmlhandbook for creating the html versions of the docbook docs") -# This option enables the reduced link interface for libs on UNIX -# -# The purpose of the KDE4_DISABLE_PROPERTY_ variable is to be used as a prefix for -# the target property LINK_INTERFACE_LIBRARIES. If it is empty, the property will have its -# correct name, if it's not empty, it will be a different name, i.e. the actual property -# will not be set, i.e. disabled. See kdelibs/kdecore/CMakeLists.txt for an example. -# -# By default (i.e. also for Windows) make it non-empty, so the property name will -# change from "LINK_INTERFACE_LIBRARIES" to "DISABLED_LINK_INTERFACE_LIBRARIES", -# which is a different (non-existing) target property, and so setting that property -# won't have an effect -set(KDE4_DISABLE_PROPERTY_ "DISABLED_") +# Remove this below once it's sure it really works, Alex + +# # This option enables the reduced link interface for libs on UNIX +# # +# # The purpose of the KDE4_DISABLE_PROPERTY_ variable is to be used as a prefix for +# # the target property LINK_INTERFACE_LIBRARIES. If it is empty, the property will have its +# # correct name, if it's not empty, it will be a different name, i.e. the actual property +# # will not be set, i.e. disabled. See kdelibs/kdecore/CMakeLists.txt for an example. +# # +# # By default (i.e. also for Windows) make it non-empty, so the property name will +# # change from "LINK_INTERFACE_LIBRARIES" to "DISABLED_LINK_INTERFACE_LIBRARIES", +# # which is a different (non-existing) target property, and so setting that property +# # won't have an effect + +# disable this for now for Windows, since there is an issue with the use of "debug" and +# "optimized" in the LINK_INTERFACE_LIBRARIES target property, Alex +if (WIN32) + set(KDE4_DISABLE_PROPERTY_ "DISABLED_") +endif(WIN32) -option(KDE4_ENABLE_EXPERIMENTAL_LIB_EXPORT "Enable the experimental reduced library exports" FALSE) -# If enabled, make it empty, so the property will keep it's actual name. -# and the LINK_INTERFACE_LIBRARIES property will be set. -if (KDE4_ENABLE_EXPERIMENTAL_LIB_EXPORT) - set(KDE4_DISABLE_PROPERTY_ ) -endif (KDE4_ENABLE_EXPERIMENTAL_LIB_EXPORT) +# option(KDE4_ENABLE_EXPERIMENTAL_LIB_EXPORT "Enable the experimental reduced library exports" FALSE) +# # If enabled, make it empty, so the property will keep it's actual name. +# # and the LINK_INTERFACE_LIBRARIES property will be set. +# if (KDE4_ENABLE_EXPERIMENTAL_LIB_EXPORT) +# set(KDE4_DISABLE_PROPERTY_ ) +# endif (KDE4_ENABLE_EXPERIMENTAL_LIB_EXPORT) if( KDE4_ENABLE_FINAL) @@ -537,7 +563,19 @@ endif(KDE4_ENABLE_FINAL) # info from "http://www.linuxfromscratch.org/hlfs/view/unstable/glibc/chapter02/pie.html" option(KDE4_ENABLE_FPIE "Enable platform supports PIE linking") -set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" ) +# If we are building ! kdelibs, check where kdelibs are installed. +# If they are installed in a directory which contains "lib64", we default to "64" for LIB_SUFFIX, +# so the current project will by default also go into lib64. +# The same for lib32. Alex +set(_Init_LIB_SUFFIX "") +if ("${KDE4_LIB_DIR}" MATCHES lib64) + set(_Init_LIB_SUFFIX 64) +endif ("${KDE4_LIB_DIR}" MATCHES lib64) +if ("${KDE4_LIB_DIR}" MATCHES lib32) + set(_Init_LIB_SUFFIX 32) +endif ("${KDE4_LIB_DIR}" MATCHES lib32) + +set(LIB_SUFFIX "${_Init_LIB_SUFFIX}" CACHE STRING "Define suffix of directory name (32/64)" ) ########## the following are directories where stuff will be installed to ########### @@ -687,40 +725,24 @@ set(INSTALL_TARGETS_DEFAULT_ARGS RUNTIME DESTINATION "${BIN_INSTALL_DIR}" # on the Mac support an extra install directory for application bundles starting with cmake 2.6 if(APPLE) - if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER "2.5") - set(INSTALL_TARGETS_DEFAULT_ARGS ${INSTALL_TARGETS_DEFAULT_ARGS} - BUNDLE DESTINATION "${BUNDLE_INSTALL_DIR}" ) - endif("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER "2.5") + set(INSTALL_TARGETS_DEFAULT_ARGS ${INSTALL_TARGETS_DEFAULT_ARGS} + BUNDLE DESTINATION "${BUNDLE_INSTALL_DIR}" ) endif(APPLE) ############## add some more default search paths ############### # -# always search in the directory where cmake is installed -# and in the current installation prefix # the KDE4_xxx_INSTALL_DIR variables are empty when building kdelibs itself # and otherwise point to the kde4 install dirs -# they will be set by default starting with cmake 2.6.0, maybe already 2.4.8 - -# also add the install directory of the running cmake to the search directories -# CMAKE_ROOT is CMAKE_INSTALL_PREFIX/share/cmake, so we need to go two levels up -get_filename_component(_CMAKE_INSTALL_DIR "${CMAKE_ROOT}" PATH) -get_filename_component(_CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" PATH) set(CMAKE_SYSTEM_INCLUDE_PATH ${CMAKE_SYSTEM_INCLUDE_PATH} - "${KDE4_INCLUDE_INSTALL_DIR}" - "${_CMAKE_INSTALL_DIR}/include" - "${CMAKE_INSTALL_PREFIX}/include" ) + "${KDE4_INCLUDE_INSTALL_DIR}") set(CMAKE_SYSTEM_PROGRAM_PATH ${CMAKE_SYSTEM_PROGRAM_PATH} - "${KDE4_BIN_INSTALL_DIR}" - "${_CMAKE_INSTALL_DIR}/bin" - "${CMAKE_INSTALL_PREFIX}/bin" ) + "${KDE4_BIN_INSTALL_DIR}" ) set(CMAKE_SYSTEM_LIBRARY_PATH ${CMAKE_SYSTEM_LIBRARY_PATH} - "${KDE4_LIB_INSTALL_DIR}" - "${_CMAKE_INSTALL_DIR}/lib" - "${CMAKE_INSTALL_PREFIX}/lib" ) + "${KDE4_LIB_INSTALL_DIR}" ) # under Windows dlls may be also installed in bin/ if(WIN32) @@ -946,9 +968,7 @@ endif(MSVC) if (CMAKE_COMPILER_IS_GNUCXX) - if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 2.5) - set (CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES} "Debugfull") - endif("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 2.5) + set (CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES} "Debugfull") set (KDE4_ENABLE_EXCEPTIONS -fexceptions) # Select flags. @@ -1057,9 +1077,7 @@ endif (CMAKE_COMPILER_IS_GNUCXX) if (CMAKE_C_COMPILER MATCHES "icc") - if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 2.5) - set (CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES} "Debugfull") - endif("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 2.5) + set (CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES} "Debugfull") set (KDE4_ENABLE_EXCEPTIONS -fexceptions) # Select flags. @@ -1104,13 +1122,13 @@ macro (KDE4_PRINT_RESULTS) # inside kdelibs the include dir and lib dir are internal, not "found" if (NOT _kdeBootStrapping) if(KDE4_INCLUDE_DIR) - message(STATUS "Found KDE 4.1 include dir: ${KDE4_INCLUDE_DIR}") + message(STATUS "Found KDE 4.2 include dir: ${KDE4_INCLUDE_DIR}") else(KDE4_INCLUDE_DIR) message(STATUS "ERROR: unable to find KDE 4 headers") endif(KDE4_INCLUDE_DIR) if(KDE4_LIB_DIR) - message(STATUS "Found KDE 4.1 library dir: ${KDE4_LIB_DIR}") + message(STATUS "Found KDE 4.2 library dir: ${KDE4_LIB_DIR}") else(KDE4_LIB_DIR) message(STATUS "ERROR: unable to find KDE 4 core library") endif(KDE4_LIB_DIR) |