summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <[email protected]>2022-06-22 17:05:23 +0200
committerJoerg Bornemann <[email protected]>2022-06-29 18:32:05 +0200
commit7ce82225f64d1d000b22fa59c4ef9a7f9b3a8984 (patch)
tree6899e1806bad9e0d64506b184b191ce83ec89cf7
parentc155734bfc89a62e5008e4c7b098c4c7f5c268b8 (diff)
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 <[email protected]> Reviewed-by: Alexandru Croitor <[email protected]>
-rw-r--r--examples/widgets/tools/echoplugin/plugin/CMakeLists.txt3
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt3
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt3
-rw-r--r--examples/widgets/tools/styleplugin/plugin/CMakeLists.txt3
-rw-r--r--src/corelib/Qt6CoreMacros.cmake2
-rw-r--r--src/corelib/doc/src/cmake/qt_add_plugin.qdoc4
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