1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
5\page qt-import-qml-plugins.html
6\ingroup cmake-commands-qtqml
8\title qt_import_qml_plugins
9\target qt6_import_qml_plugins
11\brief Ensures QML plugins needed by a target are imported for static builds.
18qt_import_qml_plugins(target)
21\versionlessCMakeCommandsNote qt6_import_qml_plugins()
25\note This command only has any effect if Qt was built statically. If called
26 using a non-static Qt, it will do nothing and return immediately.
28\c{qt_import_qml_plugins()} runs \c{qmlimportscanner} on the \c target
29immediately as part of the call (unless the \c{NO_IMPORT_SCAN} option was
30passed to \l{qt6_add_qml_module}{qt_add_qml_module()} when defining the QML
31module). It finds the static QML plugins used by the
32\c target and links it to those plugins so that they are part of the executable
33or shared library that \c target represents. The search follows QML module
36Because the call to \c{qmlimportscanner} runs at configure time rather than
37generation or build time, \c{qt_import_qml_plugins()} only knows about the
38information recorded on the \c target (or other targets it links or imports)
39at the time \c{qt_import_qml_plugins()} is called. Any linking or import
40relationships added after this call will not be considered. Therefore, this
41command should be called as late as possible in the \c{target}'s directory
42scope so that all the linking and import relationships are known.
44If \c target was created using \l{qt6_add_executable}{qt_add_executable()},
45projects would not normally need to call \c{qt_import_qml_plugins()} directly.
46When Qt is built statically, the command is called automatically as part of
47\l{qt6_add_executable#Finalization}{target finalization} if \c target links to
48the Qml library. By default, this finalization occurs at the end of the same
49directory scope in which the \c target was created. If the \c target was
50created using the standard CMake \c{add_executable()} command instead, the
51project needs to call \c{qt_import_qml_plugins()} itself.
53\sa Q_IMPORT_QML_PLUGIN