From bee6f47d224e4e9f35d8994efa8d7c969a06d2c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 25 Jul 2022 15:28:31 +0200 Subject: [PATCH] cmake: Teach qt_internal_extend_target about PLUGIN_TYPES Change-Id: I2e8a3faa6ada66a644dceeb98f9ba8e994db4192 Reviewed-by: Alexandru Croitor --- cmake/QtGlobalStateHelpers.cmake | 20 ++++++++++++++++++++ cmake/QtModuleHelpers.cmake | 14 +------------- cmake/QtTargetHelpers.cmake | 4 ++++ 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/cmake/QtGlobalStateHelpers.cmake b/cmake/QtGlobalStateHelpers.cmake index bb5a289c857..b498be8a94c 100644 --- a/cmake/QtGlobalStateHelpers.cmake +++ b/cmake/QtGlobalStateHelpers.cmake @@ -31,6 +31,26 @@ function(qt_internal_clear_qt_repo_known_plugin_types) set(QT_REPO_KNOWN_PLUGIN_TYPES "" CACHE INTERNAL "Known current repo Qt plug-in types" FORCE) endfunction() +function(qt_internal_add_plugin_types target plugin_types) + # Update the variable containing the list of plugins for the given plugin type + foreach(plugin_type ${plugin_types}) + qt_get_sanitized_plugin_type("${plugin_type}" plugin_type) + set_property(TARGET "${target}" APPEND PROPERTY MODULE_PLUGIN_TYPES "${plugin_type}") + qt_internal_add_qt_repo_known_plugin_types("${plugin_type}") + endforeach() + + # Save the non-sanitized plugin type values for qmake consumption via .pri files. + set_property(TARGET "${target}" + APPEND PROPERTY QMAKE_MODULE_PLUGIN_TYPES "${plugin_types}") + + # Export the plugin types. + get_property(export_properties TARGET ${target} PROPERTY EXPORT_PROPERTIES) + if(NOT MODULE_PLUGIN_TYPES IN_LIST export_properties) + set_property(TARGET ${target} APPEND PROPERTY + EXPORT_PROPERTIES MODULE_PLUGIN_TYPES) + endif() +endfunction() + function(qt_internal_add_qt_repo_known_plugin_types) set(QT_REPO_KNOWN_PLUGIN_TYPES ${QT_REPO_KNOWN_PLUGIN_TYPES} ${ARGN} CACHE INTERNAL "Known current repo Qt plug-in types" FORCE) diff --git a/cmake/QtModuleHelpers.cmake b/cmake/QtModuleHelpers.cmake index 087816a4bbb..a02e7db3245 100644 --- a/cmake/QtModuleHelpers.cmake +++ b/cmake/QtModuleHelpers.cmake @@ -396,19 +396,7 @@ function(qt_internal_add_module target) if(NOT arg_HEADER_MODULE) # Plugin types associated to a module if(NOT "x${arg_PLUGIN_TYPES}" STREQUAL "x") - # Reset the variable containing the list of plugins for the given plugin type - foreach(plugin_type ${arg_PLUGIN_TYPES}) - qt_get_sanitized_plugin_type("${plugin_type}" plugin_type) - set_property(TARGET "${target}" APPEND PROPERTY MODULE_PLUGIN_TYPES "${plugin_type}") - qt_internal_add_qt_repo_known_plugin_types("${plugin_type}") - endforeach() - - # Save the non-sanitized plugin type values for qmake consumption via .pri files. - set_property(TARGET "${target}" - PROPERTY QMAKE_MODULE_PLUGIN_TYPES "${arg_PLUGIN_TYPES}") - - # Export the plugin types. - set_property(TARGET ${target} APPEND PROPERTY EXPORT_PROPERTIES MODULE_PLUGIN_TYPES) + qt_internal_add_plugin_types("${target}" "${arg_PLUGIN_TYPES}") endif() endif() diff --git a/cmake/QtTargetHelpers.cmake b/cmake/QtTargetHelpers.cmake index c9217593085..b220fdd9a56 100644 --- a/cmake/QtTargetHelpers.cmake +++ b/cmake/QtTargetHelpers.cmake @@ -91,6 +91,10 @@ function(qt_internal_extend_target target) set_property (TARGET "${target}" APPEND PROPERTY AUTOMOC_MOC_OPTIONS "${arg_MOC_OPTIONS}" ) + # Plugin types associated to a module + if(NOT "x${arg_PLUGIN_TYPES}" STREQUAL "x") + qt_internal_add_plugin_types("${target}" "${arg_PLUGIN_TYPES}") + endif() endif() # When computing the private library dependencies, we need to check not only the known