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
qt_generate_deploy_qml_app_script.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
\page qt-generate-deploy-qml-app-script.html
6
\ingroup cmake-commands-qtqml
7
8
\title qt_generate_deploy_qml_app_script
9
\keyword qt6_generate_deploy_qml_app_script
10
11
\summary {Generate a deployment script for a QML application.}
12
13
\include cmake-find-package-qml.qdocinc
14
15
\cmakecommandsince 6.3
16
17
\include cmake-qml-qt-finalize-target-warning.qdocinc warning
18
19
\section1 Synopsis
20
21
\badcode
22
qt_generate_deploy_qml_app_script(
23
TARGET <target>
24
OUTPUT_SCRIPT <var>
25
[NO_UNSUPPORTED_PLATFORM_ERROR]
26
[NO_TRANSLATIONS]
27
[NO_COMPILER_RUNTIME]
28
[NO_PLUGINS] # since Qt 6.10
29
[EXCLUDE_PLUGIN_TYPES type_or_target...] # since Qt 6.10
30
[INCLUDE_PLUGIN_TYPES type_or_target...] # since Qt 6.10
31
[EXCLUDE_PLUGINS name...] # since Qt 6.10
32
[INCLUDE_PLUGINS name...] # since Qt 6.10
33
[DEPLOY_TOOL_OPTIONS ...]
34
[DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM]
35
[MACOS_BUNDLE_POST_BUILD]
36
[PRE_INCLUDE_REGEXES regexes...]
37
[PRE_EXCLUDE_REGEXES regexes...]
38
[POST_INCLUDE_REGEXES regexes...]
39
[POST_EXCLUDE_REGEXES regexes...]
40
[POST_INCLUDE_FILES files...]
41
[POST_EXCLUDE_FILES files...]
42
)
43
\endcode
44
45
\versionlessCMakeCommandsNote qt6_generate_deploy_qml_app_script()
46
47
\section1 Description
48
49
Installing an executable target that is also a QML module requires deploying
50
a number of things in addition to the target itself. Qt libraries and other
51
libraries from the project, Qt plugins, and the runtime parts of all QML modules
52
the application uses may all need to be installed too. The installed layout
53
is also going to be different for macOS app bundles compared to other platforms.
54
The \c{qt_generate_deploy_qml_app_script()} is a convenience command intended
55
to simplify that process, similar to what
56
\l{qt6_generate_deploy_app_script}{qt_generate_deploy_app_script()} does for
57
non-QML applications.
58
59
The command expects the application to follow Qt's recommended install
60
directory structure fairly closely. That structure is based on CMake's default
61
install layout, as determined by \l{GNUInstallDirs} (except for macOS app
62
bundles, which follow Apple's requirements instead). QML modules are installed
63
to the appropriate location for the platform. For macOS bundles, each QML
64
module's \c{qmldir} file is installed under the appropriate subdirectory below
65
\c{Resources/qml} and the module's plugin (if present) is installed under
66
\c{PlugIns}. The app bundle is assumed to be installed directly to the base
67
installation location (see the \l{Example} further below). For all other platforms,
68
both the \c{qmldir} and the module's plugin are installed under the appropriate
69
subdirectory below \c{qml}, which itself is relative to the base installation
70
location.
71
72
\c{qt_generate_deploy_qml_app_script()} generates a script whose name will be
73
stored in the variable named by the \c{OUTPUT_SCRIPT} option. That script
74
is only written at CMake generate-time. It is intended to be used with the
75
\l{install(SCRIPT)} command, which should come after the application's target
76
has been installed using \l{install(TARGETS)}.
77
78
The deployment script will call
79
\l{qt6_deploy_qml_imports}{qt_deploy_qml_imports()} with a suitable set of
80
options for the standard install layout. For macOS app bundles and Windows
81
targets, it will then also call
82
\l{qt6_deploy_runtime_dependencies}{qt_deploy_runtime_dependencies()}, again
83
with suitable options for the standard install layout.
84
85
Calling \c{qt_generate_deploy_qml_app_script()} for a platform that is not
86
supported by \c{qt_deploy_runtime_dependencies} will result in a fatal error,
87
unless the \c{NO_UNSUPPORTED_PLATFORM_ERROR} option is given. When the option
88
is given and the project is built for an unsupported platform, neither QML modules
89
nor regular runtime dependencies will be installed.
90
To ensure that the QML modules are still installed, specify both the
91
\c{NO_UNSUPPORTED_PLATFORM_ERROR} and
92
\c{DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM} options.
93
The latter option will ensure that QML modules built as part of the project
94
are still installed.
95
96
The \c{MACOS_BUNDLE_POST_BUILD} option enables an extra step when \c{target}
97
is a macOS app bundle. A post-build rule will be created which uses the
98
deployment script to deploy enough of the imported QML modules to allow the
99
application to run directly from the build directory (essentially just the
100
\c{qmldir} files and symlinks to plugins). This is usually desirable to support
101
development of the application. \c{MACOS_BUNDLE_POST_BUILD} is ignored for all
102
other platforms.
103
104
On platforms other than macOS, Qt translations are automatically deployed. To
105
inhibit this behavior, specify \c{NO_TRANSLATIONS}. Use
106
\l{qt_deploy_translations}{qt_deploy_translations()} to deploy translations in a
107
customized way.
108
109
For Windows desktop applications, the required runtime files for the compiler
110
are also installed by default. To prevent this, specify \c{NO_COMPILER_RUNTIME}.
111
112
Since Qt 6.7, you can use \c{DEPLOY_TOOL_OPTIONS} to pass additional options to
113
the underlying deployment tool. This only has an effect if the underlying
114
deployment tool is either macdeployqt or windeployqt.
115
116
The options \c{PRE_INCLUDE_REGEXES}, \c{PRE_EXCLUDE_REGEXES},
117
\c{POST_INCLUDE_REGEXES}, \c{POST_EXCLUDE_REGEXES}, \c{POST_INCLUDE_FILES}, and
118
\c{POST_EXCLUDE_FILES} can be specified to control the deployment of runtime
119
dependencies. These options do not apply to all platforms and are forwarded
120
unmodified to
121
\l{qt6_deploy_runtime_dependencies}{qt_deploy_runtime_dependencies()}.
122
123
The options \c EXCLUDE_PLUGINS, \c EXCLUDE_PLUGIN_TYPES, \c INCLUDE_PLUGINS, and
124
\c INCLUDE_PLUGIN_TYPES are used to select Qt plugins. See
125
\l{qt6_deploy_runtime_dependencies}{qt_deploy_runtime_dependencies()} for their
126
documentation.
127
128
You can turn off plugin deployment altogether with the \c NO_PLUGINS option.
129
130
For deploying a non-QML application, use
131
\l{qt6_generate_deploy_app_script}{qt_generate_deploy_app_script()}
132
instead. It is an error to call both \c{qt_generate_deploy_qml_app_script()}
133
and \l{qt6_generate_deploy_app_script}{qt_generate_deploy_app_script()} for the
134
same target.
135
136
\sa {qt6_standard_project_setup}{qt_standard_project_setup()},
137
{qt6_generate_deploy_app_script}{qt_generate_deploy_app_script()}
138
139
\section1 Example
140
141
The following example shows how to deploy a QtQuick app.
142
143
\badcode
144
cmake_minimum_required(VERSION 3.16...3.22)
145
project(MyThings)
146
147
find_package(Qt6 6.3 REQUIRED COMPONENTS Core Qml)
148
qt_standard_project_setup()
149
150
qt_add_executable(MyApp main.cpp)
151
qt_add_qml_module(MyApp
152
URI Application
153
VERSION 1.0
154
QML_FILES main.qml MyThing.qml
155
)
156
157
install(TARGETS MyApp
158
BUNDLE DESTINATION .
159
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
160
)
161
162
qt_generate_deploy_qml_app_script(
163
TARGET MyApp
164
OUTPUT_SCRIPT deploy_script
165
MACOS_BUNDLE_POST_BUILD
166
NO_UNSUPPORTED_PLATFORM_ERROR
167
DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM
168
)
169
install(SCRIPT ${deploy_script})
170
\endcode
171
172
The following example shows how to pass additional options to the underlying
173
deployment tool.
174
175
\badcode
176
set(deploy_tool_options_arg "")
177
if(APPLE)
178
set(deploy_tool_options_arg --hardened-runtime)
179
elseif(WIN32)
180
set(deploy_tool_options_arg --no-compiler-runtime)
181
endif()
182
183
qt_generate_deploy_qml_app_script(
184
...
185
DEPLOY_TOOL_OPTIONS ${deploy_tool_options_arg}
186
)
187
install(SCRIPT ${deploy_script})
188
\endcode
189
*/
qtdeclarative
src
qml
doc
src
cmake
qt_generate_deploy_qml_app_script.qdoc
Generated on
for Qt by
1.14.0