1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
5\page qt-import-plugins.html
6\ingroup cmake-commands-qtcore
8\title qt_import_plugins
9\keyword qt6_import_plugins
11\summary {Specifies a custom set of plugins to import or exclude.}
13\include cmake-find-package-core.qdocinc
15\cmakecommandsince 5.14
20qt_import_plugins(target
23 [INCLUDE_BY_TYPE plugin_type plugin ...]
24 [EXCLUDE_BY_TYPE plugin_type]
29\versionlessCMakeCommandsNote qt6_import_plugins()
33Specifies a custom set of plugins to import. The optional arguments:
34\c INCLUDE, \c EXCLUDE, \c INCLUDE_BY_TYPE, and \c EXCLUDE_BY_TYPE,
35can be used more than once.
38\li \c INCLUDE -- can be used to specify a list of plugins to import.
39\li \c EXCLUDE -- can be used to specify a list of plugins to exclude.
40\li \c INCLUDE_BY_TYPE -- can be used to override the list of plugins to
41 import for a certain plugin type.
42\li \c EXCLUDE_BY_TYPE -- can be used to specify a plugin type to exclude;
43 then no plugins of that type are imported.
44\li \c NO_DEFAULT -- prevent the default plugins from being included
45 automatically (for example, the default platform plugin).
48Qt provides plugin types such as \c imageformats, \c platforms,
51\section2 Dynamic plugins
53If plugins are dynamic libraries, the function controls the plugin deployment.
54Using this function, you may exclude specific plugin types from
55being packaged into an Android APK, for example:
58qt_add_executable(MyApp ...)
60qt_import_plugins(MyApp EXCLUDE_BY_TYPE imageformats)
63In the snippet above, all plugins that have the \c imageformats type will
64be excluded when deploying \c MyApp. The resulting Android APK will not
65contain any of the \c imageformats plugins.
67If the command isn't used, the target automatically deploys all plugins that
68belong to the Qt modules that the target is linked against.
70\section2 Static plugins
72If the command isn't used the target automatically links against
73a sane set of default static plugins, for each Qt module that the target is
74linked against. For more information, see
75\l{CMake target_link_libraries Documentation}{target_link_libraries}.
77Each plugin comes with a C++ stub file that automatically
78initializes the static plugin. Consequently, any target that links against
79a plugin has this C++ file added to its \c SOURCES.
83\snippet cmake-macros/examples.cmake qt_import_plugins
85In the snippet above, the following occurs with the executable \c myapp:
88\li The \c Qt6::QCocoaIntegrationPlugin is imported into myapp.
89\li The \c Qt6::QMinimalIntegrationPlugin plugin is
90 excluded from being automatically imported into myapp.
91\li The default list of plugins for \c imageformats is
92 overridden to only include Qt6::QGifPlugin and Qt6::QJpegPlugin.
93\li All \c sqldrivers plugins are excluded from automatic importing.
96\sa{qt6_import_qml_plugins}{qt_import_qml_plugins()}