qt_import_plugins
Specifies a custom set of plugins to import for a static Qt build.
The command is defined in the Core
component of the Qt6
package, which can be loaded like so:
find_package(Qt6 REQUIRED COMPONENTS Core)
This command was introduced in Qt 5.14.
Synopsis
qt_import_plugins(target [INCLUDE plugin ...] [EXCLUDE plugin ...] [INCLUDE_BY_TYPE plugin_type plugin ...] [EXCLUDE_BY_TYPE plugin_type] [NO_DEFAULT] )
If versionless commands are disabled, use qt6_import_plugins()
instead. It supports the same set of arguments as this command.
Description
Specifies a custom set of plugins to import. The optional arguments: INCLUDE
, EXCLUDE
, INCLUDE_BY_TYPE
, and EXCLUDE_BY_TYPE
, can be used more than once.
INCLUDE
– can be used to specify a list of plugins to import.EXCLUDE
– can be used to specify a list of plugins to exclude.INCLUDE_BY_TYPE
– can be used to override the list of plugins to import for a certain plugin type.EXCLUDE_BY_TYPE
– can be used to specify a plugin type to exclude; then no plugins of that type are imported.NO_DEFAULT
– prevent the default plugins from being included automatically (for example, the default platform plugin).
Qt provides plugin types such as imageformats
, platforms
, and sqldrivers
.
If the command isn't used the target automatically links against a sane set of default plugins, for each Qt module that the target is linked against. For more information, see target_link_libraries.
Each plugin comes with a C++ stub file that automatically initializes the plugin. Consequently, any target that links against a plugin has this C++ file added to its SOURCES
.
Note: This command imports plugins from static Qt builds only. On shared builds, it does nothing.
Examples
qt_add_executable(myapp main.cpp) target_link_libraries(myapp Qt::Gui Qt::Sql) qt_import_plugins(myapp INCLUDE Qt::QCocoaIntegrationPlugin EXCLUDE Qt::QMinimalIntegrationPlugin INCLUDE_BY_TYPE imageformats Qt::QGifPlugin Qt::QJpegPlugin EXCLUDE_BY_TYPE sqldrivers )
In the snippet above, the following occurs with the executable myapp
:
- The
Qt6::QCocoaIntegrationPlugin
is imported into myapp. - The
Qt6::QMinimalIntegrationPlugin
plugin is excluded from being automatically imported into myapp. - The default list of plugins for
imageformats
is overridden to only include Qt6::QGifPlugin and Qt6::QJpegPlugin. - All
sqldrivers
plugins are excluded from automatic importing.
See also qt_import_qml_plugins().
© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.