From 7ce82225f64d1d000b22fa59c4ef9a7f9b3a8984 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 22 Jun 2022 17:05:23 +0200 Subject: [PATCH] CMake: Let qt6_add_plugin accept sources The commands qt6_add_executable and qt6_add_library both accept a list of sources that get automatically added to the created target. Extend qt6_add_plugin to also accept sources for consistency. Fixes: QTBUG-104189 Change-Id: Iad5d8c5b31551663be155d068d55e770e1a91b27 Reviewed-by: Qt CI Bot Reviewed-by: Alexandru Croitor --- examples/widgets/tools/echoplugin/plugin/CMakeLists.txt | 3 --- .../tools/plugandpaint/plugins/basictools/CMakeLists.txt | 3 --- .../tools/plugandpaint/plugins/extrafilters/CMakeLists.txt | 3 --- examples/widgets/tools/styleplugin/plugin/CMakeLists.txt | 3 --- src/corelib/Qt6CoreMacros.cmake | 2 +- src/corelib/doc/src/cmake/qt_add_plugin.qdoc | 4 ++++ 6 files changed, 5 insertions(+), 13 deletions(-) diff --git a/examples/widgets/tools/echoplugin/plugin/CMakeLists.txt b/examples/widgets/tools/echoplugin/plugin/CMakeLists.txt index 7d63180a87b..25b10b5072c 100644 --- a/examples/widgets/tools/echoplugin/plugin/CMakeLists.txt +++ b/examples/widgets/tools/echoplugin/plugin/CMakeLists.txt @@ -1,8 +1,5 @@ qt_add_plugin(echoplugin CLASS_NAME EchoPlugin -) - -target_sources(echoplugin PRIVATE echoplugin.cpp echoplugin.h ) diff --git a/examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt b/examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt index 638bb53ef60..2ff6787f22d 100644 --- a/examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt +++ b/examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt @@ -1,9 +1,6 @@ qt_add_plugin(pnp_basictools STATIC CLASS_NAME BasicToolsPlugin -) - -target_sources(pnp_basictools PRIVATE basictoolsplugin.cpp basictoolsplugin.h ) diff --git a/examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt b/examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt index 4a3dd45de9d..d47e9fb6b6e 100644 --- a/examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt +++ b/examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt @@ -1,8 +1,5 @@ qt_add_plugin(pnp_extrafilters CLASS_NAME ExtraFiltersPlugin -) - -target_sources(pnp_extrafilters PRIVATE extrafiltersplugin.cpp extrafiltersplugin.h ) diff --git a/examples/widgets/tools/styleplugin/plugin/CMakeLists.txt b/examples/widgets/tools/styleplugin/plugin/CMakeLists.txt index fb2b877ca6a..b8c7289bedf 100644 --- a/examples/widgets/tools/styleplugin/plugin/CMakeLists.txt +++ b/examples/widgets/tools/styleplugin/plugin/CMakeLists.txt @@ -1,8 +1,5 @@ qt_add_plugin(simplestyleplugin CLASS_NAME SimpleStylePlugin -) - -target_sources(simplestyleplugin PRIVATE simplestyle.cpp simplestyle.h simplestyleplugin.cpp simplestyleplugin.h ) diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index e58ebd5d2be..b343634736b 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -2328,7 +2328,7 @@ function(qt6_add_plugin target) set(type_to_create MODULE) endif() - _qt_internal_add_library(${target} ${type_to_create}) + _qt_internal_add_library(${target} ${type_to_create} ${arg_UNPARSED_ARGUMENTS}) get_target_property(target_type "${target}" TYPE) if (target_type STREQUAL "STATIC_LIBRARY") diff --git a/src/corelib/doc/src/cmake/qt_add_plugin.qdoc b/src/corelib/doc/src/cmake/qt_add_plugin.qdoc index 89a68dbee2f..e4bacc36a9f 100644 --- a/src/corelib/doc/src/cmake/qt_add_plugin.qdoc +++ b/src/corelib/doc/src/cmake/qt_add_plugin.qdoc @@ -21,6 +21,7 @@ qt_add_plugin(target [SHARED | STATIC] [CLASS_NAME class_name] [OUTPUT_TARGETS variable_name] + sources... ) \endcode @@ -37,6 +38,9 @@ By default, the plugin will be created as a \c STATIC library if Qt was built statically, or as a \c MODULE library otherwise. You can override this default by explicitly providing the \c STATIC or \c SHARED option. +Any \c{sources} provided will be passed through to the internal call to +\c{add_library()}. + \note Non-static plugins are meant to be loaded dynamically at runtime, not linked to at build time. CMake differentiates between these two scenarios by providing the \c MODULE library type for dynamically loaded libraries, and