diff options
| -rw-r--r-- | modules/FindKDE4Internal.cmake | 4 | ||||
| -rw-r--r-- | modules/FindQt4.cmake | 166 | ||||
| -rw-r--r-- | modules/Qt4ConfigDependentSettings.cmake | 4 | 
3 files changed, 117 insertions, 57 deletions
| diff --git a/modules/FindKDE4Internal.cmake b/modules/FindKDE4Internal.cmake index 569776a6..1ce3a7cb 100644 --- a/modules/FindKDE4Internal.cmake +++ b/modules/FindKDE4Internal.cmake @@ -337,6 +337,10 @@ if( ${QT_MIN_VERSION} VERSION_LESS "4.5.0" )    set(QT_MIN_VERSION "4.5.0")  endif( ${QT_MIN_VERSION} VERSION_LESS "4.5.0" ) +# Tell FindQt4.cmake to point the QT_QTFOO_LIBRARY targets at the imported targets +# for the Qt libraries, so we get full handling of release and debug versions of the  +# Qt libs and are flexible regarding the install location of Qt under Windows: +set(QT_USE_IMPORTED_TARGETS TRUE)  #this line includes FindQt4.cmake, which searches the Qt library and headers  # TODO: we should check here that all necessary modules of Qt have been found, e.g. QtDBus diff --git a/modules/FindQt4.cmake b/modules/FindQt4.cmake index c5fc6b06..0c392676 100644 --- a/modules/FindQt4.cmake +++ b/modules/FindQt4.cmake @@ -52,6 +52,18 @@  #                    QT_USE_PHONON  #                    QT_USE_QTSCRIPTTOOLS  # +#  QT_USE_IMPORTED_TARGETS  +#        If this variable is set to TRUE, FindQt4.cmake will create imported +#        library targets for the various Qt libraries and set the  +#        library variables like QT_QTCORE_LIBRARY to point at these imported +#        targets instead of the library file on disk. This provides much better  +#        handling of the release and debug versions of the Qt libraries and is  +#       also always backwards compatible, except for the case that dependencies +#       of libraries are exported, these will then also list the names of the  +#       imported targets as dependency and not the file location on disk. This +#       is much more flexible, but requires that FindQt4.cmake is executed before +#       such an exported dependency file is processed. +#  # There are also some files that need processing by some Qt tools such as moc  # and uic.  Listed below are macros that may be used to process those files.  #   @@ -361,10 +373,10 @@ IF(QT_QT_LIBRARY)  ENDIF(QT_QT_LIBRARY) -IF (QT4_QMAKE_FOUND  AND  Qt4ImportedTarget__QtCore) +IF (QT4_QMAKE_FOUND  AND  Qt4::QtCore)     # Check already done in this cmake run, nothing more to do     RETURN() -ENDIF (QT4_QMAKE_FOUND  AND  Qt4ImportedTarget__QtCore) +ENDIF (QT4_QMAKE_FOUND  AND  Qt4::QtCore)  # check that QT_NO_DEBUG is defined for release configurations  MACRO(QT_CHECK_FLAG_EXISTS FLAG VAR DOC) @@ -891,42 +903,86 @@ IF (QT4_QMAKE_FOUND)    #    ############################################ -  MACRO (_QT4_ADJUST_LIB_VARS basename) -    # The name of the imported targets, i.e. the prefix "Qt4ImportedTarget__" must not change, +  # On OSX when Qt is found as framework, never use the imported targets for now, since  +  # in this case the handling of the framework directory currently does not work correctly. +  IF(QT_USE_FRAMEWORKS) +    SET(QT_USE_IMPORTED_TARGETS FALSE) +  ENDIF(QT_USE_FRAMEWORKS) + + +  MACRO (_QT4_ADJUST_LIB_VARS _camelCaseBasename) + +    STRING(TOUPPER "${_camelCaseBasename}" basename) + +    # The name of the imported targets, i.e. the prefix "Qt4::" 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(NOT TARGET Qt4::${_camelCaseBasename}) +        ADD_LIBRARY(Qt4::${_camelCaseBasename} UNKNOWN IMPORTED )          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}" ) +          SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +          SET_PROPERTY(TARGET Qt4::${_camelCaseBasename}        PROPERTY IMPORTED_LOCATION_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) +          SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) +          SET_PROPERTY(TARGET Qt4::${_camelCaseBasename}        PROPERTY IMPORTED_LOCATION_DEBUG "${QT_${basename}_LIBRARY_DEBUG}" )          ENDIF (QT_${basename}_LIBRARY_DEBUG) +      ENDIF(NOT TARGET Qt4::${_camelCaseBasename}) + +      # If QT_USE_IMPORTED_TARGETS is enabled, the QT_QTFOO_LIBRARY variables are set to point at these +      # imported targets. This works better in general, and is also in almost all cases fully +      # backward compatible. The only issue is when a project A which had this enabled then exports its  +      # libraries via export or EXPORT_LIBRARY_DEPENDENCIES(). In this case the libraries from project +      # A will depend on the imported Qt targets, and the names of these imported targets will be stored +      # in the dependency files on disk. This means when a project B then uses project A, these imported +      # targets must be created again, otherwise e.g. "Qt4__QtCore" will be interpreted as name of a  +      # library file on disk, and not as a target, and linking will fail: +      IF(QT_USE_IMPORTED_TARGETS) +          SET(QT_${basename}_LIBRARY       Qt4::${_camelCaseBasename} ) +          SET(QT_${basename}_LIBRARIES     Qt4::${_camelCaseBasename} ) +      ELSE(QT_USE_IMPORTED_TARGETS) + +        # 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) + +      ENDIF(QT_USE_IMPORTED_TARGETS) + +message(STATUS "QT_${basename}_LIBRARY: ${QT_${basename}_LIBRARY}") + +      SET(QT_${basename}_FOUND 1) -        SET(QT_${basename}_LIBRARY       Qt4ImportedTarget__${basename} ) -        SET(QT_${basename}_LIBRARIES     Qt4ImportedTarget__${basename} ) - -        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) @@ -941,39 +997,39 @@ IF (QT4_QMAKE_FOUND)    # Set QT_xyz_LIBRARY variable and add     # library include path to QT_INCLUDES -  _QT4_ADJUST_LIB_VARS(QTCORE) -  _QT4_ADJUST_LIB_VARS(QTGUI) -  _QT4_ADJUST_LIB_VARS(QT3SUPPORT) -  _QT4_ADJUST_LIB_VARS(QTASSISTANT) -  _QT4_ADJUST_LIB_VARS(QTASSISTANTCLIENT) -  _QT4_ADJUST_LIB_VARS(QTCLUCENE) -  _QT4_ADJUST_LIB_VARS(QTDBUS) -  _QT4_ADJUST_LIB_VARS(QTDESIGNER) -  _QT4_ADJUST_LIB_VARS(QTDESIGNERCOMPONENTS) -  _QT4_ADJUST_LIB_VARS(QTHELP) -  _QT4_ADJUST_LIB_VARS(QTMULTIMEDIA) -  _QT4_ADJUST_LIB_VARS(QTNETWORK) -  _QT4_ADJUST_LIB_VARS(QTNSPLUGIN) -  _QT4_ADJUST_LIB_VARS(QTOPENGL) -  _QT4_ADJUST_LIB_VARS(QTSCRIPT) -  _QT4_ADJUST_LIB_VARS(QTSCRIPTTOOLS) -  _QT4_ADJUST_LIB_VARS(QTSQL) -  _QT4_ADJUST_LIB_VARS(QTSVG) -  _QT4_ADJUST_LIB_VARS(QTTEST) -  _QT4_ADJUST_LIB_VARS(QTUITOOLS) -  _QT4_ADJUST_LIB_VARS(QTWEBKIT) -  _QT4_ADJUST_LIB_VARS(QTXML) -  _QT4_ADJUST_LIB_VARS(QTXMLPATTERNS) -  _QT4_ADJUST_LIB_VARS(PHONON) +  _QT4_ADJUST_LIB_VARS(QtCore) +  _QT4_ADJUST_LIB_VARS(QtGui) +  _QT4_ADJUST_LIB_VARS(Qt3Support) +  _QT4_ADJUST_LIB_VARS(QtAssistant) +  _QT4_ADJUST_LIB_VARS(QtAssistantClient) +  _QT4_ADJUST_LIB_VARS(QtCLucene) +  _QT4_ADJUST_LIB_VARS(QtDBus) +  _QT4_ADJUST_LIB_VARS(QtDesigner) +  _QT4_ADJUST_LIB_VARS(QtDesignerComponents) +  _QT4_ADJUST_LIB_VARS(QtHelp) +  _QT4_ADJUST_LIB_VARS(QtMultimedia) +  _QT4_ADJUST_LIB_VARS(QtNetwork) +  _QT4_ADJUST_LIB_VARS(QtNsPlugin) +  _QT4_ADJUST_LIB_VARS(QtOpenGL) +  _QT4_ADJUST_LIB_VARS(QtScript) +  _QT4_ADJUST_LIB_VARS(QtScriptTools) +  _QT4_ADJUST_LIB_VARS(QtSql) +  _QT4_ADJUST_LIB_VARS(QtSvg) +  _QT4_ADJUST_LIB_VARS(QtTest) +  _QT4_ADJUST_LIB_VARS(QtUiTools) +  _QT4_ADJUST_LIB_VARS(QtWebKit) +  _QT4_ADJUST_LIB_VARS(QtXml) +  _QT4_ADJUST_LIB_VARS(QtXmlPatterns) +  _QT4_ADJUST_LIB_VARS(phonon)    # platform dependent libraries    IF(Q_WS_X11) -    _QT4_ADJUST_LIB_VARS(QTMOTIF) +    _QT4_ADJUST_LIB_VARS(QtMotif)    ENDIF(Q_WS_X11)    IF(WIN32) -    _QT4_ADJUST_LIB_VARS(QTMAIN) -    _QT4_ADJUST_LIB_VARS(QAXSERVER) -    _QT4_ADJUST_LIB_VARS(QAXCONTAINER) +    _QT4_ADJUST_LIB_VARS(qtmain) +    _QT4_ADJUST_LIB_VARS(QAxServer) +    _QT4_ADJUST_LIB_VARS(QAxContainer)    ENDIF(WIN32)    # If Qt is installed as a framework, we need to add QT_QTCORE_LIBRARY here (which diff --git a/modules/Qt4ConfigDependentSettings.cmake b/modules/Qt4ConfigDependentSettings.cmake index f6062a74..d6fc2d44 100644 --- a/modules/Qt4ConfigDependentSettings.cmake +++ b/modules/Qt4ConfigDependentSettings.cmake @@ -57,9 +57,9 @@ ELSE(WIN32)    # On other platforms, check file extension to know if its static    IF(QT_QTCORE_LIBRARY_RELEASE)      GET_FILENAME_COMPONENT(qtcore_lib_ext "${QT_QTCORE_LIBRARY_RELEASE}" EXT) -    IF(${qtcore_lib_ext} STREQUAL ${CMAKE_STATIC_LIBRARY_SUFFIX}) +    IF("${qtcore_lib_ext}" STREQUAL "${CMAKE_STATIC_LIBRARY_SUFFIX}")        SET(QT_IS_STATIC 1) -    ENDIF(${qtcore_lib_ext} STREQUAL ${CMAKE_STATIC_LIBRARY_SUFFIX}) +    ENDIF("${qtcore_lib_ext}" STREQUAL "${CMAKE_STATIC_LIBRARY_SUFFIX}")    ENDIF(QT_QTCORE_LIBRARY_RELEASE)    IF(QT_QTCORE_LIBRARY_DEBUG)      GET_FILENAME_COMPONENT(qtcore_lib_ext "${QT_QTCORE_LIBRARY_DEBUG}" EXT) | 
