diff options
author | Craig Scott <craig.scott@qt.io> | 2021-03-01 17:17:54 +1100 |
---|---|---|
committer | Craig Scott <craig.scott@qt.io> | 2021-03-02 16:44:45 +1100 |
commit | c6bbca748659468b99002ec4b71559c65963b950 (patch) | |
tree | 407de19da701d639591280d82bf74c7adf0f7d2c | |
parent | b46b33c8179774a32b7f87cafdb942ab64f8e1e2 (diff) |
Make qt_get_module_for_plugin() internal and do what its name says
Contrary to its name, this command was also setting a target property.
Since it was only called in one place and that caller can just as
easily set the property instead, rename the command to make clear its
internal nature and refactor it so that the caller is responsible for
setting that property instead.
Also make it an error rather than just a warning if the command is used
for a target that doesn't belong to any module. Since this is now
unambiguously an internal command, we should always expect the target
to belong to a module.
Pick-to: 6.1
Change-Id: I929a652ddd482653868fc9df887f38f4bc7f35d9
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r-- | cmake/QtPluginHelpers.cmake | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/cmake/QtPluginHelpers.cmake b/cmake/QtPluginHelpers.cmake index 6ac981f0d1..a90bd995bb 100644 --- a/cmake/QtPluginHelpers.cmake +++ b/cmake/QtPluginHelpers.cmake @@ -128,8 +128,8 @@ function(qt_internal_add_plugin target) # Save the Qt module in the plug-in's properties if(NOT plugin_type_escaped STREQUAL "qml_plugin") - qt_get_module_for_plugin("${target}" "${plugin_type_escaped}") - get_target_property(qt_module "${target}" QT_MODULE) + qt_internal_get_module_for_plugin("${target}" "${plugin_type_escaped}" qt_module) + set_target_properties("${target}" PROPERTIES QT_MODULE "${qt_module}") set(plugin_install_package_suffix "${qt_module}") endif() @@ -328,8 +328,7 @@ function(qt_get_sanitized_plugin_type plugin_type out_var) endfunction() # Utility function to find the module to which a plug-in belongs. -# This will set the QT_MODULE target property on the plug-in - e.g. "Gui", "Sql"... -function(qt_get_module_for_plugin target target_type) +function(qt_internal_get_module_for_plugin target target_type out_var) qt_internal_get_qt_all_known_modules(known_modules) qt_get_sanitized_plugin_type("${target_type}" target_type) @@ -344,14 +343,10 @@ function(qt_get_module_for_plugin target target_type) get_target_property(plugin_types "${QT_CMAKE_EXPORT_NAMESPACE}::${qt_module}" MODULE_PLUGIN_TYPES) - if(plugin_types) - foreach(plugin_type ${plugin_types}) - if("${target_type}" STREQUAL "${plugin_type}") - set_target_properties("${target}" PROPERTIES QT_MODULE "${qt_module}") - return() - endif() - endforeach() + if(plugin_types AND target_type IN_LIST plugin_types) + set("${out_var}" "${qt_module}" PARENT_SCOPE) + return() endif() endforeach() - message(AUTHOR_WARNING "The plug-in '${target}' does not belong to any Qt module.") + message(FATAL_ERROR "The plug-in '${target}' does not belong to any Qt module.") endfunction() |