The qt6_add_qml_module() command accepts an OUTPUT_DIRECTORY argument which specifies where the QML module's qmldir file, typeinfo file and plugin library will be created. When that argument is not used, the default value is based on the QT_QML_OUTPUT_DIRECTORY variable, if it is set. If QT_QML_OUTPUT_DIRECTORY is not set, the default value depends on the type of backing target (see the OUTPUT_DIRECTORY documentation for details).

When QT_QML_OUTPUT_DIRECTORY is set, the default output directory will be formed by appending the QML module's target path (which is based on the module URI) to QT_QML_OUTPUT_DIRECTORY. The QT_QML_OUTPUT_DIRECTORY will also be added to the import path of the qmllint and qmlcachegen tooling targets, allowing them to find other QML modules under the same base location. This allows the project to use a source directory structure that doesn't exactly match the URI structure of the QML modules, or to merge sets of QML modules under a common base point.

When building QML modules for Android, QT_QML_OUTPUT_DIRECTORY is set to ${CMAKE_BINARY_DIR}/android-qml by default. The Android deployment routine uses this directory to locate the required QML modules in the build tree. The output directory of a QML module can also be set for a project or for each QML module target by the user and it can therefore differ from the Android default directory. In this case, to successfully deploy the executable on Android, the target path of the QML module must be based on the module URI. Also, the QT_QML_IMPORT_PATH property of the executable target must contain the import paths of all QML modules that are built in the project tree, have a custom output directory, and are used by the executable target. This behavior will likely change in a future Qt version due to improvements in the build system implementation.

© 2022 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.