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-integration.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2026 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4
/*!
5
\page qtqml-cmake-integration.html
6
\title CMake Integration for QML
7
\brief CMake commands, properties, and policies for QML module development.
8
9
Qt provides extensive CMake integration for building QML modules and applications.
10
11
\section1 Core CMake Commands
12
13
\section2 qt_add_qml_module
14
15
The \l{qt_add_qml_module} command is the primary function for creating QML modules in CMake.
16
It handles QML type registration, resource embedding, plugin creation, and integration with
17
Qt's build system, providing a declarative way to define all aspects of a QML module.
18
19
\section2 qt_target_qml_sources
20
21
The \l{qt_target_qml_sources} command adds QML files and resources to an existing QML module
22
target. This is useful for organizing large modules or conditionally including QML files based
23
on build configuration.
24
25
\section2 qt_add_qml_plugin
26
27
The \l{qt_add_qml_plugin} command creates a QML plugin library that can be dynamically loaded
28
by the QML engine. While \c{qt_add_qml_module} typically handles plugin creation automatically,
29
this function provides lower-level control when needed.
30
31
\section1 Deployment Commands
32
33
\section2 qt_deploy_qml_imports
34
35
The \l{qt_deploy_qml_imports} command identifies and deploys all QML imports used by your
36
application, including their dependencies. This ensures that all necessary QML modules and
37
plugins are packaged with your application.
38
39
\section2 qt_generate_deploy_qml_app_script
40
41
The \l{qt_generate_deploy_qml_app_script} command generates a platform-specific deployment
42
script that handles copying QML modules, plugins, and other resources to the correct locations
43
in your application bundle or installation directory.
44
45
\section2 qt_import_qml_plugins
46
47
The \l{qt_import_qml_plugins} command ensures that QML plugins are properly linked into
48
statically-built applications, generating the necessary initialization code to register
49
the plugins with the QML engine.
50
51
\section1 Advanced Commands
52
53
\section2 qt_generate_foreign_qml_types
54
55
The \l{qt_generate_foreign_qml_types} command creates QML type registrations for C++ types
56
that are defined in other libraries or modules. This enables you to expose third-party or
57
Qt types to QML without modifying their source code.
58
59
\section2 qt_query_qml_module
60
61
The \l{qt_query_qml_module} command retrieves information about a QML module, such as its
62
URI, version, plugin target, and type information file paths. This is useful for build
63
system introspection and tooling integration.
64
65
\section2 qt_target_compile_qml_to_cpp
66
67
The \l{qt_target_compile_qml_to_cpp} command enables compilation of QML files to C++ using
68
\l{qmltc}(the QML type compiler). This provides an alternative to component-based
69
instantiation with improved performance for statically-known QML types.
70
71
\section2 qt_add_qml_preview
72
73
The \l{qt_add_qml_preview} command sets up \l{qmlpreview} live-reload support for an
74
executable target that loads QML from one or more \l{qt_add_qml_module} targets, but is
75
not itself a QML module. It creates an additional \c{<target>_qmlpreview} build target that
76
can be used to preview the executable's QML files.
77
78
\section1 CMake Variables and Properties
79
80
Qt Qml provides several CMake variables and properties to configure QML module behavior:
81
82
\section2 Global Variables
83
84
\l{CMake Global Variables in Qt6 Qml} control default behavior across all QML modules in your
85
project. These include variables for output directories, cache file generation, and tooling
86
integration, allowing you to configure QML compilation settings at a project-wide level.
87
88
\section2 Global Properties
89
90
\l{CMake Global Properties in Qt6 Qml} affect how the build system processes QML modules and can be
91
used to customize aspects like linter target organization and build-time code generation.
92
93
\section2 Source File Properties
94
95
\l{CMake Source File Properties in Qt6 Qml} allow fine-grained control over individual QML files
96
within a module. You can use these properties to mark files as singletons, exclude them from
97
compilation steps, specify custom type names, or control other per-file behaviors in the QML type
98
system.
99
100
\section2 Target Properties
101
102
\l{CMake Target Properties in Qt6 Qml} let you fine-tune the behavior of individual targets,
103
for example to opt a target out of behavior that would otherwise be enabled for it project-wide,
104
such as automatic \l{qmlpreview} target creation.
105
106
\section1 CMake Policies
107
108
Qt Qml defines several CMake policies to control backward compatibility and behavior.
109
110
\section2 CMake Policies for QML
111
112
The \l{CMake Policies for QML} page provides an overview of all QML-related CMake policies
113
and how they affect module behavior. Policies allow you to opt-in to new behaviors while
114
maintaining compatibility with existing projects.
115
116
\sa {QML Modules}, {qt_add_qml_module}, {Writing QML Modules}
117
*/
qtdeclarative
src
qml
doc
src
cmake
cmake-integration.qdoc
Generated on
for Qt by
1.16.1