Introduce Qt<Module>TransitiveExtras.cmake for Qt modules
This file sets the transitive module properties provided by Qt Module that is built using CMake versions < 3.30. The idea is to not limit user projects capabilities and allow using transitive Qt Module properties if user CMake version allows it. If Qt Modules are built using CMake versions >= 3.30 this code is noop, since values are stored directly in the respective INTERFACE_properties. Change-Id: I5a0bc0aa4f79a04c81dfa0fee1d37cfee5935b0f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
fb4c1257d8
commit
c6f15f57cd
@ -227,6 +227,7 @@ function(qt_internal_get_qt_build_private_files_to_install out_var)
|
|||||||
ModuleDescription.json.in
|
ModuleDescription.json.in
|
||||||
PkgConfigLibrary.pc.in
|
PkgConfigLibrary.pc.in
|
||||||
Qt3rdPartyLibraryConfig.cmake.in
|
Qt3rdPartyLibraryConfig.cmake.in
|
||||||
|
QtTransitiveExtras.cmake.in
|
||||||
QtBaseTopLevelHelpers.cmake
|
QtBaseTopLevelHelpers.cmake
|
||||||
QtBuild.cmake
|
QtBuild.cmake
|
||||||
QtBuildHelpers.cmake
|
QtBuildHelpers.cmake
|
||||||
|
@ -216,6 +216,17 @@ function(qt_internal_add_module target)
|
|||||||
"_qt_package_version"
|
"_qt_package_version"
|
||||||
"_qt_package_name"
|
"_qt_package_name"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(CMAKE_VERSION VERSION_LESS 3.30)
|
||||||
|
# For the CMake versions higher than 3.30 the corresponding INTERFACE_
|
||||||
|
# properties will be in Qt<Module>Targets.cmake without extra code
|
||||||
|
# needed.
|
||||||
|
list(APPEND export_properties
|
||||||
|
"_qt_transitive_compile_properties"
|
||||||
|
"_qt_transitive_link_properties"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT is_internal_module)
|
if(NOT is_internal_module)
|
||||||
set_target_properties(${target} PROPERTIES
|
set_target_properties(${target} PROPERTIES
|
||||||
_qt_is_public_module TRUE
|
_qt_is_public_module TRUE
|
||||||
@ -728,6 +739,21 @@ function(qt_internal_add_module target)
|
|||||||
list(APPEND extra_cmake_includes "${INSTALL_CMAKE_NAMESPACE}${target}Macros.cmake")
|
list(APPEND extra_cmake_includes "${INSTALL_CMAKE_NAMESPACE}${target}Macros.cmake")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_VERSION VERSION_LESS 3.30)
|
||||||
|
# For the CMake versions higher than 3.30 the corresponding INTERFACE_
|
||||||
|
# properties will be in Qt<Module>Targets.cmake without extra code
|
||||||
|
# needed.
|
||||||
|
configure_file(
|
||||||
|
"${QT_CMAKE_DIR}/QtTransitiveExtras.cmake.in"
|
||||||
|
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}TransitiveExtras.cmake"
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
list(APPEND extra_cmake_files
|
||||||
|
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}TransitiveExtras.cmake")
|
||||||
|
list(APPEND extra_cmake_includes
|
||||||
|
"${INSTALL_CMAKE_NAMESPACE}${target}TransitiveExtras.cmake")
|
||||||
|
endif()
|
||||||
|
|
||||||
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigExtras.cmake.in")
|
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigExtras.cmake.in")
|
||||||
if(target STREQUAL Core)
|
if(target STREQUAL Core)
|
||||||
if(NOT "${QT_NAMESPACE}" STREQUAL "")
|
if(NOT "${QT_NAMESPACE}" STREQUAL "")
|
||||||
|
38
cmake/QtTransitiveExtras.cmake.in
Normal file
38
cmake/QtTransitiveExtras.cmake.in
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# Copyright (C) 2025 The Qt Company Ltd.
|
||||||
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
# This file sets the transitive properties supported by Qt Libraries.
|
||||||
|
if(NOT QT_NO_CREATE_TARGETS AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.30)
|
||||||
|
foreach(_qt_@target@_transitive_property_type COMPILE LINK)
|
||||||
|
string(TOLOWER "${_qt_@target@_transitive_property_type}"
|
||||||
|
_qt_@target@_transitive_property_type_lower)
|
||||||
|
|
||||||
|
get_target_property(_qt_@target@_transitive_properties @QT_CMAKE_EXPORT_NAMESPACE@::@target@
|
||||||
|
_qt_transitive_${_qt_@target@_transitive_property_type_lower}_properties)
|
||||||
|
if(NOT _qt_@target@_transitive_properties)
|
||||||
|
continue()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
foreach(_qt_@target@_transitive_property IN LISTS _qt_@target@_transitive_properties)
|
||||||
|
string(TOLOWER "_qt_internal_${_qt_@target@_transitive_property}"
|
||||||
|
_qt_@target@_transitive_property_internal)
|
||||||
|
get_target_property(_qt_@target@_transitive_property_value
|
||||||
|
@QT_CMAKE_EXPORT_NAMESPACE@::@target@ ${_qt_@target@_transitive_property_internal})
|
||||||
|
|
||||||
|
if(_qt_@target@_transitive_property_value)
|
||||||
|
_qt_internal_add_transitive_property(@QT_CMAKE_EXPORT_NAMESPACE@::@target@
|
||||||
|
${_qt_@target@_transitive_property_type} ${_qt_@target@_transitive_property})
|
||||||
|
|
||||||
|
set_property(TARGET @QT_CMAKE_EXPORT_NAMESPACE@::@target@ PROPERTY
|
||||||
|
INTERFACE_${_qt_@target@_transitive_property}
|
||||||
|
"${_qt_@target@_transitive_property_value}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endforeach()
|
||||||
|
unset(_qt_@target@_transitive_property_value)
|
||||||
|
unset(_qt_@target@_transitive_property_internal)
|
||||||
|
unset(_qt_@target@_transitive_property)
|
||||||
|
unset(_qt_@target@_transitive_properties)
|
||||||
|
unset(_qt_@target@_transitive_property_type_lower)
|
||||||
|
unset(_qt_@target@_transitive_property_type)
|
||||||
|
endif()
|
Loading…
x
Reference in New Issue
Block a user