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 qt_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
[PRE_INCLUDE_REGEXES regexes...]
36
[PRE_EXCLUDE_REGEXES regexes...]
37
[POST_INCLUDE_REGEXES regexes...]
38
[POST_EXCLUDE_REGEXES regexes...]
39
[POST_INCLUDE_FILES files...]
40
[POST_EXCLUDE_FILES files...]
41
)
42
\endcode
43
44
\versionlessCMakeCommandsNote qt6_generate_deploy_qml_app_script()
45
46
\section1 Description
47
48
Installing an executable target that is also a QML module requires deploying
49
a number of things in addition to the target itself. Qt libraries and other
50
libraries from the project, Qt plugins, and the runtime parts of all QML modules
51
the application uses may all need to be installed too. The installed layout
52
is also going to be different for macOS app bundles compared to other platforms.
53
The \c{qt_generate_deploy_qml_app_script()} is a convenience command intended
54
to simplify that process, similar to what
55
\l qt_generate_deploy_app_script() does for
56
non-QML applications.
57
58
The command expects the application to follow Qt's recommended install
59
directory structure fairly closely. That structure is based on CMake's default
60
install layout, as determined by \l{GNUInstallDirs} (except for macOS app
61
bundles, which follow Apple's requirements instead). QML modules are installed
62
to the appropriate location for the platform. For macOS bundles, each QML
63
module's \c{qmldir} file is installed under the appropriate subdirectory below
64
\c{Resources/qml} and the module's plugin (if present) is installed under
65
\c{PlugIns}. The app bundle is assumed to be installed directly to the base
66
installation location (see the \l{#Example}{Example} further below).
67
For all other platforms, both the \c{qmldir} and the module's plugin are
68
installed under the appropriate subdirectory below \c{qml}, which itself is
69
relative to the base installation location.
70
71
\c{qt_generate_deploy_qml_app_script()} generates a script whose name will be
72
stored in the variable named by the \c{OUTPUT_SCRIPT} option. That script
73
is only written at CMake generate-time. It is intended to be used with the
74
\l{install(SCRIPT)} command, which should come after the application's target
75
has been installed using \l{install(TARGETS)}.
76
77
The deployment script will call
78
\l qt_deploy_qml_imports() with a suitable set of
79
options for the standard install layout. For macOS app bundles and Windows
80
targets, it will then also call
81
\l qt_deploy_runtime_dependencies(), again
82
with suitable options for the standard install layout.
83
84
Calling \c{qt_generate_deploy_qml_app_script()} for a platform that is not
85
supported by \c{qt_deploy_runtime_dependencies} will result in a fatal error,
86
unless the \c{NO_UNSUPPORTED_PLATFORM_ERROR} option is given. When the option
87
is given and the project is built for an unsupported platform, neither QML modules
88
nor regular runtime dependencies will be installed.
89
To ensure that the QML modules are still installed, specify both the
90
\c{NO_UNSUPPORTED_PLATFORM_ERROR} and
91
\c{DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM} options.
92
The latter option will ensure that QML modules built as part of the project
93
are still installed.
94
95
On platforms other than macOS, Qt translations are automatically deployed. To
96
inhibit this behavior, specify \c{NO_TRANSLATIONS}. Use
97
\l qt_deploy_translations() to deploy translations in a
98
customized way.
99
100
For Windows desktop applications, the required runtime files for the compiler
101
are also installed by default. To prevent this, specify \c{NO_COMPILER_RUNTIME}.
102
103
Since Qt 6.7, you can use \c{DEPLOY_TOOL_OPTIONS} to pass additional options to
104
the underlying deployment tool. This only has an effect if the underlying
105
deployment tool is either macdeployqt or windeployqt.
106
107
\note A value that contains whitespace, like a code signing identity, only reaches
108
the deployment tool unchanged if \l {QTP0007} is set to \c NEW. With the \c OLD
109
behavior, such a value is written to the generated script unquoted and gets split
110
at whitespace, which projects used to work around by adding another level of
111
quoting. Remove that extra quoting when setting the policy to \c NEW.
112
113
\note The version-less \c qt_generate_deploy_qml_app_script() forwards its
114
arguments through either a function or a macro depending on the value of
115
\l {QTP0008}. With the \c OLD behavior a value that contains a backslash or a
116
\c{${var}} reference is evaluated at macro expansion time, so a regex like
117
\c{foo\\.dylib} loses a level of escaping.
118
This affects \c{DEPLOY_TOOL_OPTIONS} and the regex and file list arguments.
119
Calling \c qt6_generate_deploy_qml_app_script() directly avoids this issue.
120
121
The options \c{PRE_INCLUDE_REGEXES}, \c{PRE_EXCLUDE_REGEXES},
122
\c{POST_INCLUDE_REGEXES}, \c{POST_EXCLUDE_REGEXES}, \c{POST_INCLUDE_FILES}, and
123
\c{POST_EXCLUDE_FILES} can be specified to control the deployment of runtime
124
dependencies. These options do not apply to all platforms and are forwarded
125
unmodified to
126
\l qt_deploy_runtime_dependencies().
127
128
The options \c EXCLUDE_PLUGINS, \c EXCLUDE_PLUGIN_TYPES, \c INCLUDE_PLUGINS, and
129
\c INCLUDE_PLUGIN_TYPES are used to select Qt plugins. See
130
\l qt_deploy_runtime_dependencies() for their
131
documentation.
132
133
You can turn off plugin deployment altogether with the \c NO_PLUGINS option.
134
135
For deploying a non-QML application, use
136
\l qt_generate_deploy_app_script()
137
instead. It is an error to call both \c{qt_generate_deploy_qml_app_script()}
138
and \l qt_generate_deploy_app_script() for the
139
same target.
140
141
\sa qt_standard_project_setup(),
142
qt_generate_deploy_app_script(),
143
{QTP0007},
144
{QTP0008}
145
146
\section1 Example
147
148
The following example shows how to deploy a Qt Quick app.
149
150
\badcode
151
cmake_minimum_required(VERSION 3.16...3.22)
152
project(MyThings)
153
154
find_package(Qt6 6.3 REQUIRED COMPONENTS Core Qml)
155
qt_standard_project_setup()
156
157
qt_add_executable(MyApp main.cpp)
158
qt_add_qml_module(MyApp
159
URI Application
160
VERSION 1.0
161
QML_FILES main.qml MyThing.qml
162
)
163
164
install(TARGETS MyApp
165
BUNDLE DESTINATION .
166
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
167
)
168
169
qt_generate_deploy_qml_app_script(
170
TARGET MyApp
171
OUTPUT_SCRIPT deploy_script
172
NO_UNSUPPORTED_PLATFORM_ERROR
173
DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM
174
)
175
install(SCRIPT ${deploy_script})
176
\endcode
177
178
The following example shows how to pass additional options to the underlying
179
deployment tool.
180
181
\badcode
182
# Pass the values on to the deploy tool unchanged, see \l {QTP0007}.
183
qt_policy(SET QTP0007 NEW)
184
185
set(deploy_tool_options_arg "")
186
if(APPLE)
187
set(deploy_tool_options_arg
188
--hardened-runtime
189
"-codesign=Developer ID Application: Joe Developer (1234567890)"
190
)
191
elseif(WIN32)
192
set(deploy_tool_options_arg --no-compiler-runtime)
193
endif()
194
195
qt_generate_deploy_qml_app_script(
196
...
197
DEPLOY_TOOL_OPTIONS ${deploy_tool_options_arg}
198
)
199
install(SCRIPT ${deploy_script})
200
\endcode
201
*/
qtdeclarative
src
qml
doc
src
cmake
qt_generate_deploy_qml_app_script.qdoc
Generated on
for Qt by
1.16.1