cmake: Generate INTERFACE targets for include-only modules.
Require CMake 3.0 if an attempt is made to use a cmake file containing an INTERFACE library. If the user is using a CMake version older than 3.0, then exclude INTERFACE libraries from dependencies of Qt modules. The Qt CI system is running CMake versions as old as 2.8.11, which makes that the current minimum version. The only header-only module existing so far is the QtUiPlugin module, which has been split out from the QtDesigner module. If using CMake 2.8, the forwarding headers in the QtDesigner module will be used, and the effect of the split out library will not be seen. If using CMake 3.0, the split out library is listed as a dependency and its transitive usage requirements such as the QT_UIPLUGIN_LIB definition are made available. Change-Id: Iecee3bbc440842dca27dc067f2a31e3526efa01b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
parent
ba5af03a5a
commit
884679a7cc
@ -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}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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\")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user