CMake: Add options to select / exclude plugins for deployment

[ChangeLog][CMake] Add the arguments INCLUDE_PLUGIN_TYPES,
EXCLUDE_PLUGIN_TYPES, INCLUDE_PLUGINS, and EXCLUDE_PLUGINS to
qt_deploy_runtime_dependencies.

The arguments are only supported on Windows with this patch.
A subsequent patch will add support on Linux.

The arguments are not supported on macOS.
The macdeployqt tool lacks these flags, unfortunately.

Change-Id: I4bacdbd6f15fcf2280d1c7cde051409b6557a008
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Joerg Bornemann 2025-03-26 13:44:59 +01:00
parent 5766d74ee1
commit 6014820fe5
2 changed files with 39 additions and 0 deletions

View File

@ -366,6 +366,10 @@ function(qt6_deploy_runtime_dependencies)
ADDITIONAL_EXECUTABLES
ADDITIONAL_LIBRARIES
ADDITIONAL_MODULES
EXCLUDE_PLUGINS
EXCLUDE_PLUGIN_TYPES
INCLUDE_PLUGINS
INCLUDE_PLUGIN_TYPES
${file_GRD_options}
DEPLOY_TOOL_OPTIONS
)
@ -463,6 +467,22 @@ function(qt6_deploy_runtime_dependencies)
if(arg_NO_PLUGINS)
list(APPEND tool_options --no-plugins)
endif()
if(DEFINED arg_EXCLUDE_PLUGIN_TYPES)
string(REPLACE ";" "," plugin_list "${arg_EXCLUDE_PLUGIN_TYPES}")
list(APPEND tool_options --skip-plugin-types "${plugin_list}")
endif()
if(DEFINED arg_INCLUDE_PLUGIN_TYPES)
string(REPLACE ";" "," plugin_list "${arg_INCLUDE_PLUGIN_TYPES}")
list(APPEND tool_options --add-plugin-types "${plugin_list}")
endif()
if(DEFINED arg_INCLUDE_PLUGINS)
string(REPLACE ";" "," plugin_list "${arg_INCLUDE_PLUGINS}")
list(APPEND tool_options --include-plugins "${plugin_list}")
endif()
if(DEFINED arg_EXCLUDE_PLUGINS)
string(REPLACE ";" "," plugin_list "${arg_EXCLUDE_PLUGINS}")
list(APPEND tool_options --exclude-plugins "${plugin_list}")
endif()
# Specify path to target Qt's qtpaths .exe or .bat file, so windeployqt deploys the correct
# libraries when cross-compiling from x86_64 to arm64 windows.

View File

@ -39,6 +39,10 @@ qt_deploy_runtime_dependencies(
[NO_OVERWRITE]
[NO_APP_STORE_COMPLIANCE]
[NO_PLUGINS] # since Qt 6.10
[EXCLUDE_PLUGIN_TYPES type...] # since Qt 6.10
[INCLUDE_PLUGIN_TYPES type...] # since Qt 6.10
[EXCLUDE_PLUGINS name...] # since Qt 6.10
[INCLUDE_PLUGINS name...] # since Qt 6.10
[NO_TRANSLATIONS]
[NO_COMPILER_RUNTIME]
[DEPLOY_TOOL_OPTIONS]
@ -191,6 +195,21 @@ Qt plugins are automatically deployed into \l QT_DEPLOY_PLUGINS_DIR.
You can turn off plugin deployment with the \c NO_PLUGINS argument.
You can include all plugins of a specific type with the \c INCLUDE_PLUGIN_TYPES
argument. You can exclude all plugins of a specific type with the \c
EXCLUDE_PLUGIN_TYPES argument. Both arguments take plugin types, e.g. \c
imageformats.
You can include or exclude specific plugins with the arguments \c
INCLUDE_PLUGINS and \c EXCLUDE_PLUGINS. Both arguments take plugin names, for
example \c qjpeg.
\note Plugin names must not be confused with plugin targets. For example, the \c
Qt6::QJpegPlugin target's plugin name is \c qjpeg.
\note The arguments \c EXCLUDE_PLUGINS, \c EXCLUDE_PLUGIN_TYPES, \c
INCLUDE_PLUGINS, and \c INCLUDE_PLUGIN_TYPES only work on Windows.
\section1 Example
The following example shows how to deploy an application \c{MyApp}.