summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <[email protected]>2025-01-23 17:21:03 +0100
committerAlexandru Croitor <[email protected]>2025-01-27 17:36:33 +0100
commitf7b8ff71778bde94741402216269c2de2dda32c1 (patch)
tree447d6625417ef3a9ea25278378f7c768cc309d34
parent6a75d0e95b16096b92f6a3d3fc286f013be0c2bd (diff)
CMake: Set versioned variables with found modules, plugins, types
Introduce two new directory-scoped variables containing versioned (prefixed with Qt6::) target names of qt modules and qt plugins found as a result of finding Qt packages: - QT_ALL_MODULES_VERSIONED_FOUND_VIA_FIND_PACKAGE - QT_ALL_PLUGINS_VERSIONED_FOUND_VIA_FIND_PACKAGE To be consistent in the naming of the variables going forward, deprecate the old QT_ALL_PLUGINS_FOUND_BY_FIND_PACKAGE variable in favor of a new QT_ALL_PLUGINS_FOUND_VIA_FIND_PACKAGE. The difference is 'BY' vs 'VIA'. The non-versioned variables are modified not to contain duplicates: - QT_ALL_MODULES_FOUND_VIA_FIND_PACKAGE - QT_ALL_PLUGINS_FOUND_VIA_FIND_PACKAGE Also remove duplicates from the variable that collects all found qt plugin types: - QT_ALL_PLUGIN_TYPES_FOUND_VIA_FIND_PACKAGE A follow-up change will collect qml plugin targets. This information can be useful to find out what Qt targets are available in a project, for example to know what plugin targets or types can be linked into another target, or which libraries can be deployed. Pick-to: 6.8 6.9 Change-Id: I4f158872f4a8f6ef6008f081270604f75b77ad9d Reviewed-by: Joerg Bornemann <[email protected]>
-rw-r--r--cmake/QtModuleConfig.cmake.in16
-rw-r--r--cmake/QtPublicPluginHelpers.cmake28
2 files changed, 39 insertions, 5 deletions
diff --git a/cmake/QtModuleConfig.cmake.in b/cmake/QtModuleConfig.cmake.in
index de243aff2b3..cd6c3427a37 100644
--- a/cmake/QtModuleConfig.cmake.in
+++ b/cmake/QtModuleConfig.cmake.in
@@ -167,18 +167,28 @@ if (TARGET @QT_CMAKE_EXPORT_NAMESPACE@::@target@)
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@[email protected]")
endif()
- list(APPEND QT_ALL_MODULES_FOUND_VIA_FIND_PACKAGE "@target@")
+ if(NOT "@target@" IN_LIST QT_ALL_MODULES_FOUND_VIA_FIND_PACKAGE)
+ list(APPEND QT_ALL_MODULES_FOUND_VIA_FIND_PACKAGE "@target@")
+ list(APPEND QT_ALL_MODULES_VERSIONED_FOUND_VIA_FIND_PACKAGE
+ "@INSTALL_CMAKE_NAMESPACE@::@target@")
+ endif()
get_target_property(_qt_module_target_type "@INSTALL_CMAKE_NAMESPACE@::@target@" TYPE)
if(NOT _qt_module_target_type STREQUAL "INTERFACE_LIBRARY")
get_target_property(_qt_module_plugin_types
@INSTALL_CMAKE_NAMESPACE@::@target@ MODULE_PLUGIN_TYPES)
if(_qt_module_plugin_types)
- list(APPEND QT_ALL_PLUGIN_TYPES_FOUND_VIA_FIND_PACKAGE "${_qt_module_plugin_types}")
+ foreach(_qt_module_plugin_type IN LISTS _qt_module_plugin_types)
+ if(NOT "${_qt_module_plugin_type}"
+ IN_LIST QT_ALL_PLUGIN_TYPES_FOUND_VIA_FIND_PACKAGE)
+ list(APPEND QT_ALL_PLUGIN_TYPES_FOUND_VIA_FIND_PACKAGE
+ "${_qt_module_plugin_type}")
+ endif()
+ endforeach()
+ unset(_qt_module_plugin_type)
endif()
endif()
-
# Load Module's BuildInternals should any exist
if (@INSTALL_CMAKE_NAMESPACE@BuildInternals_DIR AND
EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@[email protected]")
diff --git a/cmake/QtPublicPluginHelpers.cmake b/cmake/QtPublicPluginHelpers.cmake
index 3a9f18d797f..055f50711f2 100644
--- a/cmake/QtPublicPluginHelpers.cmake
+++ b/cmake/QtPublicPluginHelpers.cmake
@@ -581,10 +581,34 @@ macro(__qt_internal_include_plugin_packages target)
continue()
endif()
- list(APPEND "QT_ALL_PLUGINS_FOUND_BY_FIND_PACKAGE_${__plugin_type}" "${plugin_target}")
+ set(plugin_target_versioned "${QT_CMAKE_EXPORT_NAMESPACE}::${plugin_target}")
+
+ if(NOT "${plugin_target}"
+ IN_LIST QT_ALL_PLUGINS_FOUND_VIA_FIND_PACKAGE)
+
+ # Old compatibility name.
+ # TODO: Remove once all usages are ported.
+ list(APPEND QT_ALL_PLUGINS_FOUND_BY_FIND_PACKAGE "${plugin_target}")
+
+ # New name consistent with other such variables.
+ list(APPEND QT_ALL_PLUGINS_FOUND_VIA_FIND_PACKAGE "${plugin_target}")
+ list(APPEND QT_ALL_PLUGINS_VERSIONED_FOUND_VIA_FIND_PACKAGE
+ "${plugin_target_versioned}")
+ endif()
+
+ if(NOT "${plugin_target}" IN_LIST QT_ALL_PLUGINS_FOUND_VIA_FIND_PACKAGE_${__plugin_type})
+ # Old compatibility name.
+ # TODO: Remove once all usages are ported.
+ list(APPEND QT_ALL_PLUGINS_FOUND_BY_FIND_PACKAGE_${__plugin_type} "${plugin_target}")
+
+ # New name consistent with other such variables.
+ list(APPEND QT_ALL_PLUGINS_FOUND_VIA_FIND_PACKAGE_${__plugin_type} "${plugin_target}")
+ list(APPEND
+ QT_ALL_PLUGINS_VERSIONED_FOUND_VIA_FIND_PACKAGE_${__plugin_type}
+ "${plugin_target_versioned}")
+ endif()
# Auto-linkage should be set up only for static plugins.
- set(plugin_target_versioned "${QT_CMAKE_EXPORT_NAMESPACE}::${plugin_target}")
get_target_property(type "${plugin_target_versioned}" TYPE)
if(type STREQUAL STATIC_LIBRARY)
__qt_internal_add_static_plugin_linkage(