- Qt 6.9
- Qt Qml
- qt_import_qml_plugins
- Qt 6.9.1 Reference Documentation

# qt_import_qml_plugins

This command was introduced in Qt 6.0.

## Synopsis

     qt_import_qml_plugins(target)

If versionless commands are disabled, use `qt6_import_qml_plugins()` instead. It supports the same set of arguments as this command.

## Description

Note: This command only has any effect if Qt was built statically. If called using a non-static Qt, it will do nothing and return immediately.

`qt_import_qml_plugins()` runs `qmlimportscanner` on the `target` immediately as part of the call (unless the `NO_IMPORT_SCAN` option was passed to qt_add_qml_module() when defining the QML module). It finds the static QML plugins used by the `target` and links it to those plugins so that they are part of the executable or shared library that `target` represents. The search follows QML module imports recursively.

Because the call to `qmlimportscanner` runs at configure time rather than generation or build time, `qt_import_qml_plugins()` only knows about the information recorded on the `target` (or other targets it links or imports) at the time `qt_import_qml_plugins()` is called. Any linking or import relationships added after this call will not be considered. Therefore, this command should be called as late as possible in the `target`'s directory scope so that all the linking and import relationships are known.

If `target` was created using qt_add_executable(), projects would not normally need to call `qt_import_qml_plugins()` directly. When Qt is built statically, the command is called automatically as part of target finalization if `target` links to the Qml library. By default, this finalization occurs at the end of the same directory scope in which the `target` was created. If the `target` was created using the standard CMake `add_executable()` command instead, the project needs to call `qt_import_qml_plugins()` itself.

See also Q_IMPORT_QML_PLUGIN.