qt_import_plugins(target [INCLUDE plugin ...] [EXCLUDE plugin ...] [INCLUDE_BY_TYPE plugin_type plugin ...] [EXCLUDE_BY_TYPE plugin_type])
Specifies a custom set of plugins to import. The optional arguments:
EXCLUDE_BY_TYPE, can be used more than once.
This CMake command was introduced in Qt 5.14.
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.
Qt provides plugin types such as
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
Note: This command imports plugins from static Qt builds only. On shared builds, it does nothing.
This command was introduced in Qt 5.15. You can use qt5_import_plugins in older versions of 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 Qt5::QGifPlugin Qt5::QJpegPlugin EXCLUDE_BY_TYPE sqldrivers )
In the snippet above, the following occurs with the executable
Qt::QCocoaIntegrationPluginis imported into myapp.
Qt::QMinimalIntegrationPluginplugin is excluded from being automatically imported into myapp.
imageformatsis overridden to only include Qt::QGifPlugin and Qt::QJpegPlugin.
sqldriversplugins are excluded from automatic importing.
© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.