diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf index 9f7ba46c3c..395d6f247c 100644 --- a/mkspecs/features/create_cmake.prf +++ b/mkspecs/features/create_cmake.prf @@ -173,9 +173,28 @@ contains(CONFIG, plugin) { CMAKE_MKSPEC = $$[QMAKE_XSPEC] -CMAKE_MODULE_DEPS = $$cmakeModuleList($$sort_depends(QT.$${MODULE}.depends, QT.)) -CMAKE_PARTIAL_MODULE_DEPS = $$replace(CMAKE_MODULE_DEPS, ";", ";Qt5::") -!isEmpty(CMAKE_PARTIAL_MODULE_DEPS):CMAKE_QT5_MODULE_DEPS = "Qt5::$${CMAKE_PARTIAL_MODULE_DEPS}" +sorted_deps = $$sort_depends(QT.$${MODULE}.depends, QT.) +mod_deps = +lib_deps = +aux_mod_deps = +aux_lib_deps = +# Until CMake 3.0 is the minimum requirement of Qt 5, we need to filter +# out header-only modules from dependencies. CMake 3.0 provides INTERFACE +# libraries which are equivalent to header-only modules. +for (dep, sorted_deps) { + cdep = $$cmakeModuleName($$dep) + !contains(QT.$${dep}.module_config, no_link) { + mod_deps += $$cdep + lib_deps += Qt5::$$cdep + } else { + aux_mod_deps += $$cdep + aux_lib_deps += Qt5::$$cdep + } +} +CMAKE_MODULE_DEPS = $$join(mod_deps, ";") +CMAKE_QT5_MODULE_DEPS = $$join(lib_deps, ";") +CMAKE_INTERFACE_MODULE_DEPS = $$join(aux_mod_deps, ";") +CMAKE_INTERFACE_QT5_MODULE_DEPS = $$join(aux_lib_deps, ";") CMAKE_QT_STEM = Qt$$QT_MAJOR_VERSION$${CMAKE_MODULE_NAME}$${QT_LIBINFIX} diff --git a/mkspecs/features/ctest_testcase_common.prf b/mkspecs/features/ctest_testcase_common.prf index b98a613f55..bdf40541ec 100644 --- a/mkspecs/features/ctest_testcase_common.prf +++ b/mkspecs/features/ctest_testcase_common.prf @@ -61,7 +61,12 @@ BUILD_DIR = $$replace($$list($$OUT_PWD/build), /, $$QMAKE_DIR_SEP) dependentmodules = $$resolve_depends(CMAKE_QT_MODULES_UNDER_TEST, "QT.") dependentmodules -= $$CMAKE_QT_MODULES_UNDER_TEST -dependentmodules = $$cmakeModuleList($$dependentmodules) + +mod_deps = +for (dep, dependentmodules): \ + !contains(QT.$${dep}.module_config, no_link): \ + mod_deps += $$cmakeModuleName($$dep) +dependentmodules = $$join(mod_deps, ";") contains(QT_CONFIG, angle): CMAKE_GL_DEFINES = -DQT_WITH_ANGLE=True !contains(QT_CONFIG, egl): CMAKE_GL_DEFINES += -DNO_EGL=True diff --git a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in index d1dfeed535..70b9ed941a 100644 --- a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in +++ b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in @@ -1,7 +1,13 @@ +!!IF !equals(TEMPLATE, aux) if (CMAKE_VERSION VERSION_LESS 2.8.3) message(FATAL_ERROR \"Qt 5 requires at least CMake version 2.8.3\") endif() +!!ELSE +if (CMAKE_VERSION VERSION_LESS 3.0.0) + message(FATAL_ERROR \"Qt 5 $${CMAKE_MODULE_NAME} module requires at least CMake version 3.0.0\") +endif() +!!ENDIF !!IF !isEmpty(CMAKE_USR_MOVE_WORKAROUND) !!IF !isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE) @@ -46,7 +52,7 @@ but not all the files it references. endif() endmacro() - +!!IF !equals(TEMPLATE, aux) macro(_populate_$${CMAKE_MODULE_NAME}_target_properties Configuration LIB_LOCATION IMPLIB_LOCATION) set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration}) @@ -80,6 +86,7 @@ macro(_populate_$${CMAKE_MODULE_NAME}_target_properties Configuration LIB_LOCATI endif() !!ENDIF endmacro() +!!ENDIF if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME}) @@ -143,13 +150,20 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME}) endif() !!ENDIF +!!IF !equals(TEMPLATE, aux) set(Qt5$${CMAKE_MODULE_NAME}_INCLUDE_DIRS ${_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS}) set(Qt5$${CMAKE_MODULE_NAME}_DEFINITIONS -D$${MODULE_DEFINE}) set(Qt5$${CMAKE_MODULE_NAME}_COMPILE_DEFINITIONS $${MODULE_DEFINE}) - +!!ENDIF // TEMPLATE != aux set(_Qt5$${CMAKE_MODULE_NAME}_MODULE_DEPENDENCIES \"$${CMAKE_MODULE_DEPS}\") +!!IF !isEmpty(CMAKE_INTERFACE_MODULE_DEPS) + if (NOT CMAKE_VERSION VERSION_LESS 3.0.0) + list(APPEND _Qt5$${CMAKE_MODULE_NAME}_MODULE_DEPENDENCIES \"$${CMAKE_INTERFACE_MODULE_DEPS}\") + endif() +!!ENDIF + set(_Qt5$${CMAKE_MODULE_NAME}_FIND_DEPENDENCIES_REQUIRED) if (Qt5$${CMAKE_MODULE_NAME}_FIND_REQUIRED) set(_Qt5$${CMAKE_MODULE_NAME}_FIND_DEPENDENCIES_REQUIRED REQUIRED) @@ -163,7 +177,9 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME}) set(_Qt5$${CMAKE_MODULE_NAME}_FIND_VERSION_EXACT EXACT) endif() +!!IF !equals(TEMPLATE, aux) set(Qt5$${CMAKE_MODULE_NAME}_EXECUTABLE_COMPILE_FLAGS \"\") +!!ENDIF // TEMPLATE != aux foreach(_module_dep ${_Qt5$${CMAKE_MODULE_NAME}_MODULE_DEPENDENCIES}) if (NOT Qt5${_module_dep}_FOUND) @@ -180,26 +196,40 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME}) return() endif() +!!IF !equals(TEMPLATE, aux) list(APPEND Qt5$${CMAKE_MODULE_NAME}_INCLUDE_DIRS \"${Qt5${_module_dep}_INCLUDE_DIRS}\") list(APPEND Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"${Qt5${_module_dep}_PRIVATE_INCLUDE_DIRS}\") list(APPEND Qt5$${CMAKE_MODULE_NAME}_DEFINITIONS ${Qt5${_module_dep}_DEFINITIONS}) list(APPEND Qt5$${CMAKE_MODULE_NAME}_COMPILE_DEFINITIONS ${Qt5${_module_dep}_COMPILE_DEFINITIONS}) list(APPEND Qt5$${CMAKE_MODULE_NAME}_EXECUTABLE_COMPILE_FLAGS ${Qt5${_module_dep}_EXECUTABLE_COMPILE_FLAGS}) +!!ENDIF // TEMPLATE != aux endforeach() +!!IF !equals(TEMPLATE, aux) list(REMOVE_DUPLICATES Qt5$${CMAKE_MODULE_NAME}_INCLUDE_DIRS) list(REMOVE_DUPLICATES Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS) list(REMOVE_DUPLICATES Qt5$${CMAKE_MODULE_NAME}_DEFINITIONS) list(REMOVE_DUPLICATES Qt5$${CMAKE_MODULE_NAME}_COMPILE_DEFINITIONS) list(REMOVE_DUPLICATES Qt5$${CMAKE_MODULE_NAME}_EXECUTABLE_COMPILE_FLAGS) +!!ENDIF // TEMPLATE != aux set(_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES \"$${CMAKE_QT5_MODULE_DEPS}\") +!!IF !isEmpty(CMAKE_INTERFACE_QT5_MODULE_DEPS) + if (NOT CMAKE_VERSION VERSION_LESS 3.0.0) + list(APPEND _Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES \"$${CMAKE_INTERFACE_QT5_MODULE_DEPS}\") + endif() +!!ENDIF + !!IF !isEmpty(CMAKE_STATIC_TYPE) add_library(Qt5::$${CMAKE_MODULE_NAME} STATIC IMPORTED) set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY IMPORTED_LINK_INTERFACE_LANGUAGES "CXX") +!!ELSE +!!IF equals(TEMPLATE, aux) + add_library(Qt5::$${CMAKE_MODULE_NAME} INTERFACE IMPORTED) !!ELSE add_library(Qt5::$${CMAKE_MODULE_NAME} SHARED IMPORTED) !!ENDIF +!!ENDIF !!IF !isEmpty(CMAKE_BUILD_IS_FRAMEWORK) set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY FRAMEWORK 1) !!ENDIF @@ -209,6 +239,7 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME}) set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY INTERFACE_COMPILE_DEFINITIONS $${MODULE_DEFINE}) +!!IF !equals(TEMPLATE, aux) !!IF !isEmpty(CMAKE_RELEASE_TYPE) !!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD) _populate_$${CMAKE_MODULE_NAME}_target_properties(RELEASE \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" \"\" ) @@ -282,6 +313,11 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME}) !!ENDIF // CMAKE_FIND_OTHER_LIBRARY_BUILD !!ENDIF // CMAKE_DEBUG_TYPE +!!ELSE // TEMPLATE != aux + set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES + INTERFACE_LINK_LIBRARIES \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}\" + ) +!!ENDIF // TEMPLATE != aux file(GLOB pluginTargets \"${CMAKE_CURRENT_LIST_DIR}/Qt5$${CMAKE_MODULE_NAME}_*Plugin.cmake\")