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_deploy_runtime_dependencies.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-deploy-runtime-dependencies.html
6
\ingroup cmake-commands-qtcore
7
8
\title qt_deploy_runtime_dependencies
9
\keyword qt6_deploy_runtime_dependencies
10
11
\summary {Deploy Qt plugins, Qt and non-Qt libraries needed by an executable.}
12
13
\include cmake-find-package-core.qdocinc
14
15
Unlike most other CMake commands provided by Qt, \c{qt_deploy_runtime_dependencies()}
16
can only be called from a deployment script. It cannot be called directly by the
17
project during the configure stage.
18
19
\cmakecommandsince 6.3
20
\note This command does not usually need to be called directly. It is used
21
internally by other higher level commands, but projects wishing to
22
implement more customized deployment logic may find it useful.
23
24
\section1 Synopsis
25
26
\badcode
27
qt_deploy_runtime_dependencies(
28
EXECUTABLE executable
29
[ADDITIONAL_EXECUTABLES files...]
30
[ADDITIONAL_LIBRARIES files...]
31
[ADDITIONAL_MODULES files...]
32
[GENERATE_QT_CONF]
33
[BIN_DIR bin_dir]
34
[LIBEXEC_DIR libexec_dir]
35
[LIB_DIR lib_dir]
36
[PLUGINS_DIR plugins_dir]
37
[QML_DIR qml_dir]
38
[VERBOSE]
39
[NO_OVERWRITE]
40
[NO_APP_STORE_COMPLIANCE]
41
[NO_PLUGINS] # since Qt 6.10
42
[EXCLUDE_PLUGIN_TYPES type...] # since Qt 6.10
43
[INCLUDE_PLUGIN_TYPES type...] # since Qt 6.10
44
[EXCLUDE_PLUGINS name...] # since Qt 6.10
45
[INCLUDE_PLUGINS name...] # since Qt 6.10
46
[NO_TRANSLATIONS]
47
[NO_COMPILER_RUNTIME]
48
[DEPLOY_TOOL_OPTIONS]
49
[PRE_INCLUDE_REGEXES regexes...]
50
[PRE_EXCLUDE_REGEXES regexes...]
51
[POST_INCLUDE_REGEXES regexes...]
52
[POST_EXCLUDE_REGEXES regexes...]
53
[POST_INCLUDE_FILES files...]
54
[POST_EXCLUDE_FILES files...]
55
)
56
\endcode
57
58
\section1 Description
59
60
When installing an application, it may be desirable to also install the
61
libraries and plugins it depends on. When the application is a macOS app bundle
62
or a Windows executable, \c{qt_deploy_runtime_dependencies()} can be called
63
from an install-time script to deploy those dependencies. It will install
64
non-system Qt libraries plus an appropriate set of Qt plugins.
65
66
On Linux, the command will deploy additional libraries, beyond just those
67
related to Qt, that are included with the project. However, when executed on
68
macOS or Windows, the command will use either \c macdeployqt or \c windeployqt,
69
which will only deploy libraries that are specific to Qt.
70
71
This command only considers runtime dependencies for which linking
72
relationships exist in the underlying binaries. It does not deploy QML modules,
73
see \l{qt6_deploy_qml_imports}{qt_deploy_qml_imports()} for that.
74
75
\section1 Arguments
76
77
The \c{EXECUTABLE} option must be provided.
78
79
The \c{executable} argument should be the path to the executable file in the
80
build directory. For example, \c{${CMAKE_CURRENT_BINARY_DIR}/MyApp.exe}, or more
81
dynamically \c{$<TARGET_FILE:MyApp>}. Specifying raw target names not wrapped in
82
a generator expression like \c{$<TARGET_FILE:>} is not supported.
83
84
For macOS app bundles, the \c{executable} argument should be a path to the
85
bundle directory, relative to the base install location.
86
For example \c{MyApp.app}, or more dynamically
87
\c{$<TARGET_FILE_NAME:MyApp>.app}.
88
Specifying raw target names not wrapped in a generator expression like
89
\c{$<TARGET_FILE_NAME:>} is not supported.
90
91
It may also be desirable to install dependencies for other binaries related to
92
the \c{executable}. For example, plugins provided by the project might have
93
further dependencies, but because those plugins won't be linked directly to the
94
executable, \c{qt_deploy_runtime_dependencies()} won't automatically discover
95
them. The \c{ADDITIONAL_EXECUTABLES}, \c{ADDITIONAL_LIBRARIES}, and
96
\c{ADDITIONAL_MODULES} options can be used to specify additional binaries
97
whose dependencies should also be deployed (installing the named binaries
98
themselves is still the project's responsibility). The naming of these keywords
99
follows CMake's conventions, so Qt plugins would be specified using
100
\c{ADDITIONAL_MODULES}.
101
Each value should be a path relative to the base install location. The values
102
can use generator expressions, same as with the \c{EXECUTABLE} option.
103
Specifying raw target names not wrapped in a generator expression like
104
\c{$<TARGET_FILE_NAME:>} is not supported.
105
106
When installing a Windows application, it is common to need a
107
\l{Using qt.conf}{qt.conf} file when following CMake's default install
108
directory structure. If the \c{GENERATE_QT_CONF} option is given, an appropriate
109
\c{qt.conf} file will be written to the same directory as the \c{executable}.
110
The paths in that \c{qt.conf} file will be based on the \c{CMAKE_INSTALL_xxxDIR}
111
variables, whose defaults are provided by CMake's \l{GNUInstallDirs} module.
112
113
You can override some of those defaults with the parameters in the following
114
table, all of which are expected to be relative to the base install location.
115
116
\table
117
\header
118
\li parameter
119
\li affected variable
120
\li notes
121
\row
122
\li \c BIN_DIR
123
\li \l QT_DEPLOY_BIN_DIR
124
\li
125
\row
126
\li \c LIBEXEC_DIR
127
\li \l QT_DEPLOY_LIBEXEC_DIR
128
\li since Qt 6.7
129
\row
130
\li \c LIB_DIR
131
\li \l QT_DEPLOY_LIB_DIR
132
\li
133
\row
134
\li \c PLUGINS_DIR
135
\li \l QT_DEPLOY_PLUGINS_DIR
136
\li
137
\row
138
\li \c QML_DIR
139
\li \l QT_DEPLOY_QML_DIR
140
\li
141
\endtable
142
143
A \c{qt.conf} file is always written if \c{executable} is a macOS app bundle,
144
regardless of whether or not \c{GENERATE_QT_CONF} is provided. The \c{..._DIR}
145
options are also ignored in that case, since the directory layout of an app
146
bundle is dictated by Apple's requirements.
147
148
More verbose output about the deployment steps can be enabled by providing the
149
\c{VERBOSE} option. Alternatively, the \l{QT_ENABLE_VERBOSE_DEPLOYMENT}
150
variable can be set in the project before the first \c{find_package(Qt6)} call
151
to make deployment output verbose by default.
152
153
The \c{qt_deploy_runtime_dependencies()} command overwrites existing files by
154
default (some warnings may still be issued). Use the \c{NO_OVERWRITE} option
155
to prevent overwriting existing files. Note that this option currently only
156
affects macOS and Windows deployments.
157
158
By default, if \c{executable} is a macOS app bundle, only Qt plugins and Qt
159
libraries that comply with Apple's app store requirements are deployed. The
160
\c{NO_APP_STORE_COMPLIANCE} option can be given to disable that constraint.
161
162
On platforms other than macOS, Qt translations are automatically deployed. To
163
inhibit this behavior, specify \c{NO_TRANSLATIONS}. Use
164
\l{qt6_deploy_translations}{qt_deploy_translations()} to deploy translations
165
in a customized way.
166
167
For Windows desktop applications, the required runtime files for the compiler
168
are also installed by default. To prevent this, specify \c{NO_COMPILER_RUNTIME}.
169
170
Since Qt 6.7, you can use \c{DEPLOY_TOOL_OPTIONS} to pass additional options to
171
the underlying deployment tool. This only has an effect if the underlying
172
deployment tool is either macdeployqt or windeployqt.
173
174
On Linux, deploying runtime dependencies is based on CMake's
175
\c{file(GET_RUNTIME_DEPENDENCIES)} command. The options \c{PRE_INCLUDE_REGEXES},
176
\c{PRE_EXCLUDE_REGEXES}, \c{POST_INCLUDE_REGEXES}, \c{POST_EXCLUDE_REGEXES},
177
\c{POST_INCLUDE_FILES}, and \c{POST_EXCLUDE_FILES} are only meaningful in this
178
context and are forwarded unaltered to \c{file(GET_RUNTIME_DEPENDENCIES)}. See
179
the documentation of that command for details.
180
181
On Linux, runtime dependencies that are located in system library directories
182
are not deployed by default. If \c{POST_EXCLUDE_REGEXES} is specified, this
183
automatic exclusion is not performed.
184
185
The default value of \c{POST_EXCLUDE_REGEXES} is constructed from the value of
186
\l{QT_DEPLOY_IGNORED_LIB_DIRS}.
187
188
\sa {qt6_generate_deploy_app_script}{qt_generate_deploy_app_script()},
189
{qt6_deploy_qt_conf}{qt_deploy_qt_conf()},
190
{qt6_deploy_qml_imports}{qt_deploy_qml_imports()}
191
192
\section1 Controlling deployment of Qt plugins
193
194
Qt plugins are automatically deployed into \l QT_DEPLOY_PLUGINS_DIR.
195
196
You can turn off plugin deployment with the \c NO_PLUGINS argument.
197
198
You can include all plugins of a specific type with the \c INCLUDE_PLUGIN_TYPES
199
argument. You can exclude all plugins of a specific type with the \c
200
EXCLUDE_PLUGIN_TYPES argument. Both arguments take plugin types, e.g. \c
201
imageformats.
202
203
You can include or exclude specific plugins with the arguments \c
204
INCLUDE_PLUGINS and \c EXCLUDE_PLUGINS. Both arguments take plugin names, for
205
example \c qjpeg.
206
207
\note Plugin names must not be confused with plugin targets. For example, the \c
208
Qt6::QJpegPlugin target's plugin name is \c qjpeg.
209
210
\note The arguments \c EXCLUDE_PLUGINS, \c EXCLUDE_PLUGIN_TYPES, \c
211
INCLUDE_PLUGINS, and \c INCLUDE_PLUGIN_TYPES only work on Windows and Linux.
212
213
\section1 Example
214
215
The following example shows how to deploy an application \c{MyApp}.
216
217
\include cmake-deploy-runtime-dependencies.qdocinc
218
219
The following example shows how to use the \c{DEPLOY_TOOL_OPTIONS} parameter to
220
pass different options to macdeployqt and windeployqt.
221
222
\include cmake-deploy-runtime-dependencies-deploy-tool-options.qdocinc
223
224
*/
qtbase
src
corelib
doc
src
cmake
qt_deploy_runtime_dependencies.qdoc
Generated on
for Qt by
1.14.0