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 <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Joerg Bornemann 2022-06-22 17:05:23 +02:00
parent c155734bfc
commit 7ce82225f6
6 changed files with 5 additions and 13 deletions

View File

@ -1,8 +1,5 @@
qt_add_plugin(echoplugin
CLASS_NAME EchoPlugin
)
target_sources(echoplugin PRIVATE
echoplugin.cpp echoplugin.h
)

View File

@ -1,9 +1,6 @@
qt_add_plugin(pnp_basictools
STATIC
CLASS_NAME BasicToolsPlugin
)
target_sources(pnp_basictools PRIVATE
basictoolsplugin.cpp basictoolsplugin.h
)

View File

@ -1,8 +1,5 @@
qt_add_plugin(pnp_extrafilters
CLASS_NAME ExtraFiltersPlugin
)
target_sources(pnp_extrafilters PRIVATE
extrafiltersplugin.cpp extrafiltersplugin.h
)

View File

@ -1,8 +1,5 @@
qt_add_plugin(simplestyleplugin
CLASS_NAME SimpleStylePlugin
)
target_sources(simplestyleplugin PRIVATE
simplestyle.cpp simplestyle.h
simplestyleplugin.cpp simplestyleplugin.h
)

View File

@ -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")

View File

@ -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