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-module-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-modules-cmake-integration.html
6
\title Tying it all together with CMake
7
\brief Building QML modules with CMake
8
9
When creating QML modules, CMake provides the infrastructure to properly register
10
QML types, generate necessary metadata, and ensure your module is correctly packaged
11
and deployable. This page outlines the recommended workflow.
12
13
\section1 Using qt_add_qml_module
14
15
The \l{qt_add_qml_module} command is the standard and recommended way to create QML modules.
16
It handles all the complex details of QML module creation:
17
18
\code
19
qt_add_qml_module(my_qml_module
20
URI MyModule
21
QML_FILES
22
MyType.qml
23
AnotherType.qml
24
SOURCES
25
mytype.cpp mytype.h
26
)
27
\endcode
28
29
This single command:
30
\list
31
\li Creates the module target
32
\li Registers QML types from C++ and QML files
33
\li Generates a qmldir file
34
\li Handles type registration
35
\li Sets up proper import paths
36
\li Enables QML tooling support (\l{qmllint}, \l{\QMLLS}{qmlls}, etc.)
37
\endlist
38
39
\section1 Adding Further QML Files
40
41
For QML files added after the initial \c{qt_add_qml_module} call, use
42
\l{qt_target_qml_sources}:
43
44
\code
45
qt_target_qml_sources(my_qml_module
46
QML_FILES
47
DynamicallyAddedType.qml
48
)
49
\endcode
50
51
This can be done based on platform, configuration or other factors.
52
53
\section1 Detailed CMake Reference
54
55
For complete details on all CMake commands, properties, variables, and policies,
56
see \l{CMake Integration for QML}.
57
58
\sa {QML Modules}, {qt_add_qml_module}
59
*/
qtdeclarative
src
qml
doc
src
qmllanguageref
modules
cmake-module-integration.qdoc
Generated on
for Qt by
1.16.1