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\summary{Base output directory below which QML modules will be created by default.}
20
21The \l qt_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{qt_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\sa {Setting CMake variables and properties}
40*/
41
42/*!
43\page cmake-variable-qt-qml-generate-qmlls-ini-no-cmake-calls.html
44\ingroup cmake-variables-qtqml
45
46\title QT_QML_GENERATE_QMLLS_INI_NO_CMAKE_CALLS
47
48\summary{Customizes the value of no-cmake-calls in .qmlls.ini files for \QMLLS.}
49\cmakevariablesince 6.10
50
51\c QT_QML_GENERATE_QMLLS_INI_NO_CMAKE_CALLS is a boolean that controls the \c no-cmake-calls value in
52\c{.qmlls.ini} files generated with the \l{QT_QML_GENERATE_QMLLS_INI} option. Set it to \c ON to disable
53CMake calls by \QMLLS.
54
55As this variable is used for IDE integration, it should normally not be set in a project itself, but
56passed to CMake via an IDE or manually by passing
57\code [text]
58-DQT_QML_GENERATE_QMLLS_INI=ON -DQT_QML_GENERATE_QMLLS_INI_NO_CMAKE_CALLS=ON
59\endcode
60to the cmake executable.
61
62This variable has no effect if \l{QT_QML_GENERATE_QMLLS_INI} is disabled.
63
64\sa QT_QML_GENERATE_QMLLS_INI, {Configuring Automatic CMake Builds}
65\sa {Setting CMake variables and properties}
66*/
67
68/*!
69\page cmake-variable-qt-qml-generate-qmlls-ini.html
70\ingroup cmake-variables-qtqml
71
72\title QT_QML_GENERATE_QMLLS_INI
73
74\summary{Enables autogeneration of .qmlls.ini files for \QMLLS.}
75\warning This variable is deprecated since Qt 6.10. No replacement needed.
76\cmakevariablesince 6.7
77
78\c QT_QML_GENERATE_QMLLS_INI is a boolean that describes whether
79\l qt_add_qml_module() calls generate \c{.qmlls.ini} files inside
80the \b{source folder}, into each subdirectory with a CMakeLists.txt file creating a QML module.
81If \c{.qmlls.ini} files already exist there, then they are overwritten.
82
83\note Using \c QT_QML_GENERATE_QMLLS_INI requires a CMake version >= 3.19.
84
85These \c{.qmlls.ini} files contain the path to the last configured build directory,
86and is needed by \l{\QMLLS} to find user defined modules. See also
87\l{\QMLLS} about the other ways of passing build folders to \QMLLS.
88
89As this variable is used for IDE integration, it should normally not be set in a project itself, but
90passed to CMake via an IDE or manually by passing
91\code [text]
92-DQT_QML_GENERATE_QMLLS_INI=ON
93\endcode
94to the cmake executable.
95
96\warning The files generated by \c QT_QML_GENERATE_QMLLS_INI are only valid for the current
97configuration and should be ignored by your version control system. For Git, add \tt{**\/.qmlls.ini}
98to your top-level project \c{.gitignore}, for example.
99The globbing is required because .qmlls.ini files are generated in \e{all source
100subdirectories} that define QML Modules.
101
102\sa QT_QML_GENERATE_QMLLS_INI_NO_CMAKE_CALLS, {Configuring Automatic CMake Builds}
103\sa {Setting CMake variables and properties}
104*/
105
106/*!
107\page cmake-variable-qt-qml-no-cachegen.html
108\ingroup cmake-variables-qtqml
109
110\title QT_QML_NO_CACHEGEN
111
112\summary{Disables compilation of QML files into bytecode or C++ code.}
113\cmakevariablesince 6.8.1
114
115\c QT_QML_NO_CACHEGEN is a CMake variable that can be set to disable the compilation of QML files
116into bytecode or C++ code for QML targets created by
117\l qt_add_qml_module().
118
119It has the same effect as setting the \c{NO_CACHEGEN} option of
120\l qt_add_qml_module(), but allows doing so on a per-directory or project
121basis.
122
123Turn on this option to reduce the number of build steps necessary to complete a build, and
124thereby shorten the develop-debug iteration cycle.
125
126To minimize application size, turn off this option, and instead use
127\l{QT_DISCARD_FILE_CONTENTS}{QT_DISCARD_FILE_CONTENTS} to remove the QML files embedded into the
128resource system.
129
130The variable can be set in the project's CMakeLists.txt as follows:
131\code [cmake]
132set(QT_QML_NO_CACHEGEN TRUE)
133qt_add_qml_module(MyModule
134 URI MyModule
135 VERSION 1.0
136 ...
137)
138\endcode
139
140\sa {Setting CMake variables and properties}
141*/
142
143/*!
144\page cmake-variable-qt-qml-generate-aotstats.html
145\ingroup cmake-variables-qtqml
146
147\title QT_QML_GENERATE_AOTSTATS
148
149\summary{Controls whether QML Compiler statistics collection is enabled.}
150\cmakevariablesince 6.8.3
151
152When a QML project is configured using \l qt_add_qml_module(), by default,
153\l{QML script compiler#Obtaining statistics about the compilation of functions and bindings}{statistics}
154from the compilation of QML code will be collected. You can explicitly opt in
155or out of this by setting the \c{QT_QML_GENERATE_AOTSTATS} variable. It can be
156set project-wide by passing
157\code [text]
158-DQT_QML_GENERATE_AOTSTATS=OFF
159\endcode
160to the CMake executable, or by setting it directly in the corresponding
161CMakeLists.txt file before the first call to \l qt_add_qml_module().
162\code [cmake]
163set(QT_QML_GENERATE_AOTSTATS OFF)
164\endcode
165
166\sa {Setting CMake variables and properties}
167*/
168
169/*!
170\page cmake-variable-qt-qmllint-no-context-property-dump.html
171\ingroup cmake-variables-qtqml
172
173\title QT_QMLLINT_CONTEXT_PROPERTY_DUMP
174
175\summary{Enables dumping of context properties in lint targets.}
176\cmakevariablesince 6.11
177
178When the \c QT_QMLLINT_CONTEXT_PROPERTY_DUMP variable is enabled, \l{qmllint-auto}{linting targets}
179created by \l qt_add_qml_module() will run \l qmlcontextpropertydump before running \l qmllint. This
180allows \l qmllint to warn on the usage of context properties in QML.
181
182To enable this feature, set the \c QT_QMLLINT_CONTEXT_PROPERTY_DUMP variable using
183one of the following methods:
184
185\list
186 \li Pass the option to the CMake executable:
187 \code [text]
188 -DQT_QMLLINT_CONTEXT_PROPERTY_DUMP=ON
189 \endcode
190
191 \li Add the setting to your \c CMakeLists.txt file before the first call to
192 \l qt_add_qml_module():
193 \code [cmake]
194 set(QT_QMLLINT_CONTEXT_PROPERTY_DUMP ON)
195 \endcode
196\endlist
197
198\sa {Setting CMake variables and properties}
199*/
200
201/*!
202\page cmake-variable-qt-qml-no-qml-preview.html
203\ingroup cmake-variables-qtqml
204
205\title QT_QML_NO_QML_PREVIEW (global property)
206
207\summary{Controls whether qmlpreview support is automatically set up for executables linking against Qt6::Qml.}
208\cmakevariablesince 6.12
209
210By default, every executable target that links against \c{Qt6::Qml}
211automatically gets \l qmlpreview support set up for it at target finalization,
212as if \l qt_add_qml_preview() had been called on it explicitly. Executable
213targets that are themselves QML modules created by \l qt_add_qml_module() are
214unaffected, as they already get \l qmlpreview support from that command.
215
216Setting this variable to a true value disables the automatic behavior for all
217targets. This skips the small amount of extra configure-time work spent
218creating a preview target for each executable, which is worthwhile for projects
219that don't use \l qmlpreview, for example applications that only drive QML
220through a \l QJSEngine for scripting, or release and CI builds where live reload
221is irrelevant. Disable it for an entire build by passing
222\code [text]
223-DQT_QML_NO_QML_PREVIEW=ON
224\endcode
225to the cmake executable, or set it in the project's \c CMakeLists.txt if preview
226is never needed.
227
228For finer control, individual targets can opt out with the
229\l{cmake-target-property-QT_QML_NO_QML_PREVIEW}{QT_QML_NO_QML_PREVIEW}
230property, or opt back in with \l qt_add_qml_preview() even when preview is
231disabled globally.
232
233\sa qt_add_qml_preview(), {cmake-target-property-QT_QML_NO_QML_PREVIEW}{QT_QML_NO_QML_PREVIEW}
234\sa {Setting CMake variables and properties}
235*/