diff options
author | Alexander Neundorf <neundorf@kde.org> | 2010-01-17 18:11:01 +0000 |
---|---|---|
committer | Alexander Neundorf <neundorf@kde.org> | 2010-01-17 18:11:01 +0000 |
commit | 08134581fe028a5dd1a94b9b8bc2022c7c1e23f9 (patch) | |
tree | 2cfe99635e0ed2b5b8202861c8ecd5af04b1dea5 | |
parent | 9c18c97448697082b34db4345d3ae527284b408a (diff) | |
download | extra-cmake-modules-08134581fe028a5dd1a94b9b8bc2022c7c1e23f9.tar.gz extra-cmake-modules-08134581fe028a5dd1a94b9b8bc2022c7c1e23f9.tar.bz2 |
-use imported targets for the Qt4 libs also in the 4.4 release branch
This fixes handling release and debug versions of Qt, and is a major improvement for the deployment of KDE under Windows.
Alex
svn path=/branches/KDE/4.4/kdelibs/; revision=1076181
-rw-r--r-- | modules/FindKDE4Internal.cmake | 16 | ||||
-rw-r--r-- | modules/FindQt4.cmake | 70 | ||||
-rw-r--r-- | modules/HandleImportedTargetsInCMakeRequiredLibraries.cmake | 16 |
3 files changed, 59 insertions, 43 deletions
diff --git a/modules/FindKDE4Internal.cmake b/modules/FindKDE4Internal.cmake index c6f5599e..569776a6 100644 --- a/modules/FindKDE4Internal.cmake +++ b/modules/FindKDE4Internal.cmake @@ -303,6 +303,10 @@ endif(POLICY CMP0011) # Only do something if it hasn't been found yet if(NOT KDE4_FOUND) +# get the directory of the current file, used later on in the file +get_filename_component( kde_cmake_module_dir ${CMAKE_CURRENT_LIST_FILE} PATH) + + include (MacroEnsureVersion) # We may only search for other packages with "REQUIRED" if we are required ourselves. @@ -317,6 +321,13 @@ else(KDE4_FIND_REQUIRED OR KDE4Internal_FIND_REQUIRED) set(_REQ_STRING_KDE4_MESSAGE "STATUS") endif(KDE4_FIND_REQUIRED OR KDE4Internal_FIND_REQUIRED) + +# Store CMAKE_MODULE_PATH and then append the current dir to it, so we are sure +# we get the FindQt4.cmake located next to us and not a different one. +# The original CMAKE_MODULE_PATH is restored later on. +set(_kde_cmake_module_path_back ${CMAKE_MODULE_PATH}) +set(CMAKE_MODULE_PATH ${kde_cmake_module_dir} ${CMAKE_MODULE_PATH} ) + # if the minimum Qt requirement is changed, change all occurrence in the # following lines if( NOT QT_MIN_VERSION ) @@ -351,6 +362,8 @@ if(NOT PERL_FOUND) message(STATUS "Perl not found") endif(NOT PERL_FOUND) +# restore the original CMAKE_MODULE_PATH +set(CMAKE_MODULE_PATH ${_kde_cmake_module_path_back}) # we check for Phonon not here, but further below, i.e. after KDELibsDependencies.cmake # has been loaded, which helps in the case that phonon is installed to the same @@ -390,9 +403,6 @@ include (CheckCXXCompilerFlag) include (CheckCXXSourceCompiles) -# get the directory of the current file, used later on in the file -get_filename_component( kde_cmake_module_dir ${CMAKE_CURRENT_LIST_FILE} PATH) - # are we trying to compile kdelibs ? kdelibs_SOURCE_DIR comes from "project(kdelibs)" in kdelibs/CMakeLists.txt # then enter bootstrap mode diff --git a/modules/FindQt4.cmake b/modules/FindQt4.cmake index 864828f8..c5fc6b06 100644 --- a/modules/FindQt4.cmake +++ b/modules/FindQt4.cmake @@ -361,10 +361,10 @@ IF(QT_QT_LIBRARY) ENDIF(QT_QT_LIBRARY) -IF (QT4_QMAKE_FOUND) +IF (QT4_QMAKE_FOUND AND Qt4ImportedTarget__QtCore) # Check already done in this cmake run, nothing more to do RETURN() -ENDIF (QT4_QMAKE_FOUND) +ENDIF (QT4_QMAKE_FOUND AND Qt4ImportedTarget__QtCore) # check that QT_NO_DEBUG is defined for release configurations MACRO(QT_CHECK_FLAG_EXISTS FLAG VAR DOC) @@ -892,43 +892,41 @@ IF (QT4_QMAKE_FOUND) ############################################ MACRO (_QT4_ADJUST_LIB_VARS basename) + # The name of the imported targets, i.e. the prefix "Qt4ImportedTarget__" must not change, + # since it is stored in EXPORT-files as name of a required library. If the name would change + # here, this would lead to the imported Qt4-library targets not being resolved by cmake anymore. IF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG) + IF(NOT TARGET Qt4ImportedTarget__${basename}) + ADD_LIBRARY(Qt4ImportedTarget__${basename} SHARED IMPORTED ) + + IF(WIN32) + SET(_QT4_LIBRARY_PROPERTY_NAME IMPLIB) + ELSE(WIN32) + SET(_QT4_LIBRARY_PROPERTY_NAME LOCATION) + ENDIF(WIN32) + + + IF (QT_${basename}_LIBRARY_RELEASE) + SET_PROPERTY(TARGET Qt4ImportedTarget__${basename} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + SET_PROPERTY(TARGET Qt4ImportedTarget__${basename} PROPERTY IMPORTED_${_QT4_LIBRARY_PROPERTY_NAME}_RELEASE "${QT_${basename}_LIBRARY_RELEASE}" ) + ENDIF (QT_${basename}_LIBRARY_RELEASE) + + IF (QT_${basename}_LIBRARY_DEBUG) + SET_PROPERTY(TARGET Qt4ImportedTarget__${basename} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + SET_PROPERTY(TARGET Qt4ImportedTarget__${basename} PROPERTY IMPORTED_${_QT4_LIBRARY_PROPERTY_NAME}_DEBUG "${QT_${basename}_LIBRARY_DEBUG}" ) + + SET_PROPERTY(TARGET Qt4ImportedTarget__${basename} PROPERTY MAP_IMPORTED_CONFIG_PROFILE DEBUG) + SET_PROPERTY(TARGET Qt4ImportedTarget__${basename} PROPERTY MAP_IMPORTED_CONFIG_DEBUGFULL DEBUG) + ENDIF (QT_${basename}_LIBRARY_DEBUG) + + SET(QT_${basename}_LIBRARY Qt4ImportedTarget__${basename} ) + SET(QT_${basename}_LIBRARIES Qt4ImportedTarget__${basename} ) - # if the release- as well as the debug-version of the library have been found: - IF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE) - # if the generator supports configuration types then set - # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value - IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) - SET(QT_${basename}_LIBRARY optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG}) - ELSE(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) - # if there are no configuration types and CMAKE_BUILD_TYPE has no value - # then just use the release libraries - SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE} ) - ENDIF(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) - SET(QT_${basename}_LIBRARIES optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG}) - ENDIF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE) - - # if only the release version was found, set the debug variable also to the release version - IF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG) - SET(QT_${basename}_LIBRARY_DEBUG ${QT_${basename}_LIBRARY_RELEASE}) - SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE}) - SET(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_RELEASE}) - ENDIF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG) - - # if only the debug version was found, set the release variable also to the debug version - IF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE) - SET(QT_${basename}_LIBRARY_RELEASE ${QT_${basename}_LIBRARY_DEBUG}) - SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_DEBUG}) - SET(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_DEBUG}) - ENDIF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE) - - # put the value in the cache: - SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY} CACHE STRING "The Qt ${basename} library" FORCE) - - IF (QT_${basename}_LIBRARY) - SET(QT_${basename}_FOUND 1) - ENDIF (QT_${basename}_LIBRARY) + IF (QT_${basename}_LIBRARY) + SET(QT_${basename}_FOUND 1) + ENDIF (QT_${basename}_LIBRARY) + ENDIF(NOT TARGET Qt4ImportedTarget__${basename}) ENDIF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG) IF (QT_${basename}_INCLUDE_DIR) diff --git a/modules/HandleImportedTargetsInCMakeRequiredLibraries.cmake b/modules/HandleImportedTargetsInCMakeRequiredLibraries.cmake index 28564ab6..e28efd44 100644 --- a/modules/HandleImportedTargetsInCMakeRequiredLibraries.cmake +++ b/modules/HandleImportedTargetsInCMakeRequiredLibraries.cmake @@ -44,15 +44,23 @@ FUNCTION(HANDLE_IMPORTED_TARGETS_IN_CMAKE_REQUIRED_LIBRARIES _RESULT) ENDIF ("${_CCSR_LOOP_COUNTER}" LESS 100) LIST(GET _importedConfigs 0 _firstImportedConfig) - GET_TARGET_PROPERTY(_firstImportedLocation ${_CURRENT_LIB} LOCATION_${_firstImportedConfig}) + IF(NOT WIN32) + GET_TARGET_PROPERTY(_firstImportedLocation ${_CURRENT_LIB} IMPORTED_LOCATION_${_firstImportedConfig}) + ELSE(NOT WIN32) + GET_TARGET_PROPERTY(_firstImportedLocation ${_CURRENT_LIB} IMPORTED_IMPLIB_${_firstImportedConfig}) + ENDIF(NOT WIN32) GET_TARGET_PROPERTY(_linkInterfaceLibs ${_CURRENT_LIB} IMPORTED_LINK_INTERFACE_LIBRARIES_${_firstImportedConfig} ) LIST(APPEND _CCSR_NEW_REQ_LIBS ${_firstImportedLocation}) # MESSAGE(STATUS "Appending lib ${_CURRENT_LIB} as ${_firstImportedLocation}") - FOREACH(_currentLinkInterfaceLib ${_linkInterfaceLibs}) + IF(_linkInterfaceLibs) + FOREACH(_currentLinkInterfaceLib ${_linkInterfaceLibs}) # MESSAGE(STATUS "Appending link interface lib ${_currentLinkInterfaceLib}") - LIST(APPEND _CCSR_NEW_REQ_LIBS ${_currentLinkInterfaceLib} ) - ENDFOREACH(_currentLinkInterfaceLib ${_linkInterfaceLibs}) + IF(_currentLinkInterfaceLib) + LIST(APPEND _CCSR_NEW_REQ_LIBS ${_currentLinkInterfaceLib} ) + ENDIF(_currentLinkInterfaceLib) + ENDFOREACH(_currentLinkInterfaceLib ${_linkInterfaceLibs}) + ENDIF(_linkInterfaceLibs) ELSE(_importedConfigs) # "Normal" libraries are just used as they are. LIST(APPEND _CCSR_NEW_REQ_LIBS ${_CURRENT_LIB} ) |