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
9Qt provides extensive CMake integration for building QML modules and applications.
10
11\section1 Core CMake Commands
12
13\section2 qt_add_qml_module
14
15The \l{qt_add_qml_module} command is the primary function for creating QML modules in CMake.
16It handles QML type registration, resource embedding, plugin creation, and integration with
17Qt's build system, providing a declarative way to define all aspects of a QML module.
18
19\section2 qt_target_qml_sources
20
21The \l{qt_target_qml_sources} command adds QML files and resources to an existing QML module
22target. This is useful for organizing large modules or conditionally including QML files based
23on build configuration.
24
25\section2 qt_add_qml_plugin
26
27The \l{qt_add_qml_plugin} command creates a QML plugin library that can be dynamically loaded
28by the QML engine. While \c{qt_add_qml_module} typically handles plugin creation automatically,
29this function provides lower-level control when needed.
30
31\section1 Deployment Commands
32
33\section2 qt_deploy_qml_imports
34
35The \l{qt_deploy_qml_imports} command identifies and deploys all QML imports used by your
36application, including their dependencies. This ensures that all necessary QML modules and
37plugins are packaged with your application.
38
39\section2 qt_generate_deploy_qml_app_script
40
41The \l{qt_generate_deploy_qml_app_script} command generates a platform-specific deployment
42script that handles copying QML modules, plugins, and other resources to the correct locations
43in your application bundle or installation directory.
44
45\section2 qt_import_qml_plugins
46
47The \l{qt_import_qml_plugins} command ensures that QML plugins are properly linked into
48statically-built applications, generating the necessary initialization code to register
49the plugins with the QML engine.
50
51\section1 Advanced Commands
52
53\section2 qt_generate_foreign_qml_types
54
55The \l{qt_generate_foreign_qml_types} command creates QML type registrations for C++ types
56that are defined in other libraries or modules. This enables you to expose third-party or
57Qt types to QML without modifying their source code.
58
59\section2 qt_query_qml_module
60
61The \l{qt_query_qml_module} command retrieves information about a QML module, such as its
62URI, version, plugin target, and type information file paths. This is useful for build
63system introspection and tooling integration.
64
65\section2 qt_target_compile_qml_to_cpp
66
67The \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
69instantiation with improved performance for statically-known QML types.
70
71\section1 CMake Variables and Properties
72
73Qt 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
78project. These include variables for output directories, cache file generation, and tooling
79integration, 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
84used 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
89within a module. You can use these properties to mark files as singletons, exclude them from
90compilation steps, specify custom type names, or control other per-file behaviors in the QML type
91system.
92
93\section1 CMake Policies
94
95Qt Qml defines several CMake policies to control backward compatibility and behavior.
96
97\section2 CMake Policies for QML
98
99The \l{CMake Policies for QML} page provides an overview of all QML-related CMake policies
100and how they affect module behavior. Policies allow you to opt-in to new behaviors while
101maintaining compatibility with existing projects.
102
103\sa {QML Modules}, {qt_add_qml_module}, {Writing QML Modules}
104*/