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
\section1 CMake Variables and Properties
72
73
Qt Qml provides several CMake variables and properties to configure QML module behavior:
74
75
\section2 Global Variables
76
77
\l{CMake Global Variables in Qt6 Qml} control default behavior across all QML modules in your
78
project. These include variables for output directories, cache file generation, and tooling
79
integration, allowing you to configure QML compilation settings at a project-wide level.
80
81
\section2 Global Properties
82
83
\l{CMake Global Properties in Qt6 Qml} affect how the build system processes QML modules and can be
84
used to customize aspects like linter target organization and build-time code generation.
85
86
\section2 Source File Properties
87
88
\l{CMake Source File Properties in Qt6 Qml} allow fine-grained control over individual QML files
89
within a module. You can use these properties to mark files as singletons, exclude them from
90
compilation steps, specify custom type names, or control other per-file behaviors in the QML type
91
system.
92
93
\section1 CMake Policies
94
95
Qt Qml defines several CMake policies to control backward compatibility and behavior.
96
97
\section2 CMake Policies for QML
98
99
The \l{CMake Policies for QML} page provides an overview of all QML-related CMake policies
100
and how they affect module behavior. Policies allow you to opt-in to new behaviors while
101
maintaining compatibility with existing projects.
102
103
\sa {QML Modules}, {qt_add_qml_module}, {Writing QML Modules}
104
*/
qtdeclarative
src
qml
doc
src
cmake
cmake-integration.qdoc
Generated on
for Qt by
1.16.1