From d6661c56222250f75de64cda09aab1f3837db58c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20K=C3=B6hne?= Date: Fri, 4 Jun 2021 08:32:33 +0200 Subject: [PATCH] CMake: Warn if qt_internal_plugin(target) does not end with 'Plugin' The logic for linking plugins in a static build in Qt6*Plugins.cmake looks up plugins that are named Qt6*PluginConfig.cmake, and the file name is computed by the target name. Not naming the target 'Plugin' therefore means it won't be picked up in static builds. Pick-to: 6.2 Task-number: QTBUG-95731 Change-Id: Ic83a29d7c91492c302eb413a69577a0c550e1a1b Reviewed-by: Joerg Bornemann --- cmake/QtPluginHelpers.cmake | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmake/QtPluginHelpers.cmake b/cmake/QtPluginHelpers.cmake index eae24faa9cb..3b9206d68bd 100644 --- a/cmake/QtPluginHelpers.cmake +++ b/cmake/QtPluginHelpers.cmake @@ -20,8 +20,9 @@ macro(qt_internal_get_internal_add_plugin_keywords option_args single_args multi endmacro() # This is the main entry point for defining Qt plugins. -# A CMake target is created with the given target. The PLUGIN_TYPE parameter is needed to place the -# plugin into the correct plugins/ sub-directory. +# A CMake target is created with the given target. +# The target name should end with "Plugin" so static plugins are linked automatically. +# The PLUGIN_TYPE parameter is needed to place the plugin into the correct plugins/ sub-directory. function(qt_internal_add_plugin target) qt_internal_set_qt_known_plugins("${QT_KNOWN_PLUGINS}" "${target}") @@ -87,6 +88,10 @@ function(qt_internal_add_plugin target) set(plugin_type "${arg_PLUGIN_TYPE}") endif() + if((NOT plugin_type STREQUAL "qml_plugin") AND (NOT target MATCHES "(.*)Plugin$")) + message(AUTHOR_WARNING "The internal plugin target name '${target}' should end with the 'Plugin' suffix.") + endif() + qt_get_sanitized_plugin_type("${plugin_type}" plugin_type_escaped) set(output_directory_default "${QT_BUILD_DIR}/${INSTALL_PLUGINSDIR}/${plugin_type}")