diff options
| author | Alexandru Croitor <alexandru.croitor@qt.io> | 2024-10-30 12:31:37 +0100 |
|---|---|---|
| committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2024-11-01 15:37:35 +0000 |
| commit | 8d93ef622085a955f0361acbea8b69de8dcd59c1 (patch) | |
| tree | 714acb82f9e7a4972a1f52f496b1a63b06108d7a | |
| parent | 45d532b788fd0df2c462fed110f50158d8b7a3fb (diff) | |
CMake: Add a global QT_QML_NO_CACHEGEN cmake variable
A new QT_QML_NO_CACHEGEN cmake variable can be set to disable
compilation of qml files into bytecode or C++ code.
The variable can be set either in a specific directory scope or in
the root of the project (to disable qml compilation for all targets).
This is just a more global version of the NO_CACHEGEN option that can
be passed to qt6_add_qml_module.
For projects with many qml files, this reduces the build time,
allowing faster development iteration times.
It is more convenient than passing NO_CACHEGEN to each created
qml module.
[ChangeLog][Build System] A new QT_QML_NO_CACHEGEN cmake variable can
be set to disable compilation of qml files for all project qml files.
Task-number: QTBUG-125631
Task-number: QTBUG-126205
Task-number: QTBUG-128323
Change-Id: I963c14ad0d07bf1f6d6205afdd0a8a90e73f025d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
(cherry picked from commit 69254dfc91c19e3005968a46bc6dbf7d8197712d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| -rw-r--r-- | src/qml/Qt6QmlMacros.cmake | 6 | ||||
| -rw-r--r-- | src/qml/doc/src/cmake/cmake-variables.qdoc | 35 |
2 files changed, 40 insertions, 1 deletions
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake index f1c5b0c3ee..aa50da4324 100644 --- a/src/qml/Qt6QmlMacros.cmake +++ b/src/qml/Qt6QmlMacros.cmake @@ -332,6 +332,10 @@ function(qt6_add_qml_module target) ) endif() + if(QT_QML_NO_CACHEGEN) + set(arg_NO_CACHEGEN TRUE) + endif() + # Other arguments and checking for invalid combinations if (NOT arg_TARGET_PATH) # NOTE: This will always be used for copying things to the build @@ -2758,7 +2762,7 @@ function(qt6_target_qml_sources target) if(arg_NO_LINT) set(no_lint TRUE) endif() - if(arg_NO_CACHEGEN) + if(arg_NO_CACHEGEN OR QT_QML_NO_CACHEGEN) set(no_cachegen TRUE) endif() if(no_qmldir MATCHES "NOTFOUND" OR arg_NO_QMLDIR_TYPES) diff --git a/src/qml/doc/src/cmake/cmake-variables.qdoc b/src/qml/doc/src/cmake/cmake-variables.qdoc index de984c88ef..7b5547a1ac 100644 --- a/src/qml/doc/src/cmake/cmake-variables.qdoc +++ b/src/qml/doc/src/cmake/cmake-variables.qdoc @@ -73,4 +73,39 @@ subdirectories} that define QML Modules. */ +/*! +\page cmake-variable-qt-qml-no-cachegen.html +\ingroup cmake-variables-qtqml + +\title QT_QML_NO_CACHEGEN + +\brief Disables compilation of QML files into bytecode or C++ code. +\cmakevariablesince 6.8.1 + +\c QT_QML_NO_CACHEGEN is a CMake variable that can be set to disable the compilation of QML files +into bytecode or C++ code for QML targets created by +\l{qt6_add_qml_module}{qt6_add_qml_module()}. + +It has the same effect as setting the \c{NO_CACHEGEN} option of +\l{qt6_add_qml_module}{qt6_add_qml_module()}, but allows doing so on a per-directory or project +basis. + +Turn on this option to reduce the number of build steps necessary to complete a build, and +thereby shorten the develop-debug iteration cycle. + +To minimize application size, turn off this option, and instead use +\l{QT_DISCARD_FILE_CONTENTS}{QT_DISCARD_FILE_CONTENTS} to remove the QML files embedded into the +resource system. + +The variable can be set in the project's CMakeLists.txt as follows: +\badcode +set(QT_QML_NO_CACHEGEN TRUE) +qt_add_qml_module(MyModule + URI MyModule + VERSION 1.0 + ... +) +\endcode + +*/ |
