Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cmake-variables.qdoc
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5\group cmake-variables-qtqml
6\title CMake Global Variables in Qt6 Qml
7
8\l{CMake Command Reference#Qt6::Qml}{CMake Commands} know about the following
9global CMake variables:
10
11*/
12
13/*!
14\page cmake-variable-qt-qml-output-directory.html
15\ingroup cmake-variables-qtqml
16
17\title QT_QML_OUTPUT_DIRECTORY
18
19\brief Base output directory below which QML modules will be created by default.
20
21The \l{qt6_add_qml_module}{qt6_add_qml_module()} command accepts an
22\c OUTPUT_DIRECTORY argument which specifies where the QML module's \c qmldir
23file, typeinfo file and plugin library will be created. When that argument is
24not used, the default value is based on the \c QT_QML_OUTPUT_DIRECTORY variable,
25if it is set. If \c QT_QML_OUTPUT_DIRECTORY is not set, the default value
26depends on the type of backing target (see the
27\l{qt6_add_qml_module#OUTPUT_DIRECTORY}{OUTPUT_DIRECTORY} documentation for
28details).
29
30When \c QT_QML_OUTPUT_DIRECTORY is set, the default output directory will be
31formed by appending the QML module's \e{target path} (which is based on the
32module URI) to \c QT_QML_OUTPUT_DIRECTORY.
33The \c QT_QML_OUTPUT_DIRECTORY will also be added to the import path of the
34\c qmllint and \c qmlcachegen tooling targets, allowing them to find other QML
35modules under the same base location. This allows the project to use a source
36directory structure that doesn't exactly match the URI structure of the QML
37modules, or to merge sets of QML modules under a common base point.
38*/
39
40/*!
41\page cmake-variable-qt-qml-generate-qmlls-ini-no-cmake-calls.html
42\ingroup cmake-variables-qtqml
43
44\title QT_QML_GENERATE_QMLLS_INI_NO_CMAKE_CALLS
45
46\brief Customizes the value of no-cmake-calls in .qmlls.ini files for \QMLLS.
47\cmakevariablesince 6.10
48
49\c QT_QML_GENERATE_QMLLS_INI_NO_CMAKE_CALLS is a boolean that controls the \c no-cmake-calls value in
50\c{.qmlls.ini} files generated with the \l{QT_QML_GENERATE_QMLLS_INI} option. Set it to \c ON to disable
51CMake calls by \QMLLS.
52
53As this variable is used for IDE integration, it should normally not be set in a project itself, but
54passed to CMake via an IDE or manually by passing
55\badcode
56-DQT_QML_GENERATE_QMLLS_INI=ON -DQT_QML_GENERATE_QMLLS_INI_NO_CMAKE_CALLS=ON
57\endcode
58to the cmake executable.
59
60This variable has no effect if \l{QT_QML_GENERATE_QMLLS_INI} is disabled.
61
62\sa QT_QML_GENERATE_QMLLS_INI, {Disabling automatic CMake builds}
63*/
64
65/*!
66\page cmake-variable-qt-qml-generate-qmlls-ini.html
67\ingroup cmake-variables-qtqml
68
69\title QT_QML_GENERATE_QMLLS_INI
70
71\brief Enables autogeneration of .qmlls.ini files for \QMLLS.
72\warning This variable is deprecated since Qt 6.10. No replacement needed.
73\cmakevariablesince 6.7
74
75\c QT_QML_GENERATE_QMLLS_INI is a boolean that describes whether
76\l{qt6_add_qml_module}{qt6_add_qml_module()} calls generate \c{.qmlls.ini} files inside
77the \b{source folder}, into each subdirectory with a CMakeLists.txt file creating a QML module.
78If \c{.qmlls.ini} files already exist there, then they are overwritten.
79
80\note Using \c QT_QML_GENERATE_QMLLS_INI requires a CMake version >= 3.19.
81
82These \c{.qmlls.ini} files contain the path to the last configured build directory,
83and is needed by \l{\QMLLS} to find user defined modules. See also
84\l{\QMLLS} about the other ways of passing build folders to \QMLLS.
85
86
87As this variable is used for IDE integration, it should normally not be set in a project itself, but
88passed to CMake via an IDE or manually by passing
89\badcode
90-DQT_QML_GENERATE_QMLLS_INI=ON
91\endcode
92to the cmake executable.
93
94\warning The files generated by \c QT_QML_GENERATE_QMLLS_INI are only valid for the current
95configuration and should be ignored by your version control system. For Git, add \tt{**\/.qmlls.ini}
96to your top-level project \c{.gitignore}, for example.
97The globbing is required because .qmlls.ini files are generated in \e{all source
98subdirectories} that define QML Modules.
99
100\sa QT_QML_GENERATE_QMLLS_INI_NO_CMAKE_CALLS, {Disabling automatic CMake builds}
101*/
102
103/*!
104\page cmake-variable-qt-qml-no-cachegen.html
105\ingroup cmake-variables-qtqml
106
107\title QT_QML_NO_CACHEGEN
108
109\brief Disables compilation of QML files into bytecode or C++ code.
110\cmakevariablesince 6.8.1
111
112\c QT_QML_NO_CACHEGEN is a CMake variable that can be set to disable the compilation of QML files
113into bytecode or C++ code for QML targets created by
114\l{qt6_add_qml_module}{qt6_add_qml_module()}.
115
116It has the same effect as setting the \c{NO_CACHEGEN} option of
117\l{qt6_add_qml_module}{qt6_add_qml_module()}, but allows doing so on a per-directory or project
118basis.
119
120Turn on this option to reduce the number of build steps necessary to complete a build, and
121thereby shorten the develop-debug iteration cycle.
122
123To minimize application size, turn off this option, and instead use
124\l{QT_DISCARD_FILE_CONTENTS}{QT_DISCARD_FILE_CONTENTS} to remove the QML files embedded into the
125resource system.
126
127The variable can be set in the project's CMakeLists.txt as follows:
128\badcode
129set(QT_QML_NO_CACHEGEN TRUE)
130qt_add_qml_module(MyModule
131 URI MyModule
132 VERSION 1.0
133 ...
134)
135\endcode
136
137*/
138
139/*!
140\page cmake-variable-qt-qml-generate-aotstats.html
141\ingroup cmake-variables-qtqml
142
143\title QT_QML_GENERATE_AOTSTATS
144
145\brief Controls whether QML Compiler statistics collection is enabled.
146\cmakevariablesince 6.8.3
147
148When a QML project is configured using \l{qt_add_qml_module}, by default,
149\l{QML script compiler#Obtaining statistics about the compilation of functions and bindings}{statistics}
150from the compilation of QML code will be collected. You can explicitly opt in
151or out of this by setting the \c{QT_QML_GENERATE_AOTSTATS} variable. It can be
152set project-wide by passing
153\badcode
154-DQT_QML_GENERATE_AOTSTATS=OFF
155\endcode
156to the CMake executable, or by setting it directly in the corresponding
157CMakeLists.txt file before the first call to \l{qt_add_qml_module}.
158\badcode
159set(QT_QML_GENERATE_AOTSTATS OFF)
160\endcode
161
162*/
163
164/*!
165\page cmake-variable-qt-qmllint-no-context-property-dump.html
166\ingroup cmake-variables-qtqml
167
168\title QT_QMLLINT_CONTEXT_PROPERTY_DUMP
169
170\brief Enables dumping of context properties in lint targets.
171\cmakevariablesince 6.11
172
173When the \c QT_QMLLINT_CONTEXT_PROPERTY_DUMP variable is enabled, \l{qmllint-auto}{linting targets}
174created by \l{qt_add_qml_module} will run \l qmlcontextpropertydump before running \l qmllint. This
175allows \l qmllint to warn on the usage of context properties in QML.
176
177To enable this feature, set the \c QT_QMLLINT_CONTEXT_PROPERTY_DUMP variable using
178one of the following methods:
179
180\list
181 \li Pass the option to the CMake executable:
182 \badcode
183 -DQT_QMLLINT_CONTEXT_PROPERTY_DUMP=ON
184 \endcode
185
186 \li Add the setting to your \c CMakeLists.txt file before the first call to
187 \l{qt_add_qml_module}:
188 \badcode
189 set(QT_QMLLINT_CONTEXT_PROPERTY_DUMP ON)
190 \endcode
191\endlist
192*/