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 qt_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
15Unlike most other CMake commands provided by Qt, \c{qt_deploy_runtime_dependencies()}
16can only be called from a deployment script. It cannot be called directly by the
17project 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
27qt_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
60When installing an application, it may be desirable to also install the
61libraries and plugins it depends on. When the application is a macOS app bundle
62or a Windows executable, \c{qt_deploy_runtime_dependencies()} can be called
63from an install-time script to deploy those dependencies. It will install
64non-system Qt libraries plus an appropriate set of Qt plugins.
65
66On Linux, the command will deploy additional libraries, beyond just those
67related to Qt, that are included with the project. However, when executed on
68macOS or Windows, the command will use either \c macdeployqt or \c windeployqt,
69which will only deploy libraries that are specific to Qt.
70
71This command only considers runtime dependencies for which linking
72relationships exist in the underlying binaries. It does not deploy QML modules,
73see \l qt_deploy_qml_imports() for that.
74
75\section1 Arguments
76
77The \c{EXECUTABLE} option must be provided.
78
79The \c{executable} argument should be the path to the executable file in the
80build directory. For example, \c{${CMAKE_CURRENT_BINARY_DIR}/MyApp.exe}, or more
81dynamically \c{$<TARGET_FILE:MyApp>}. Specifying raw target names not wrapped in
82a generator expression like \c{$<TARGET_FILE:>} is not supported.
83
84For macOS app bundles, the \c{executable} argument should be a path to the
85bundle directory, relative to the base install location.
86For example \c{MyApp.app}, or more dynamically
87\c{$<TARGET_FILE_NAME:MyApp>.app}.
88Specifying raw target names not wrapped in a generator expression like
89\c{$<TARGET_FILE_NAME:>} is not supported.
90
91It may also be desirable to install dependencies for other binaries related to
92the \c{executable}. For example, plugins provided by the project might have
93further dependencies, but because those plugins won't be linked directly to the
94executable, \c{qt_deploy_runtime_dependencies()} won't automatically discover
95them. The \c{ADDITIONAL_EXECUTABLES}, \c{ADDITIONAL_LIBRARIES}, and
96\c{ADDITIONAL_MODULES} options can be used to specify additional binaries
97whose dependencies should also be deployed (installing the named binaries
98themselves is still the project's responsibility). The naming of these keywords
99follows CMake's conventions, so Qt plugins would be specified using
100\c{ADDITIONAL_MODULES}.
101Each value should be a path relative to the base install location. The values
102can use generator expressions, same as with the \c{EXECUTABLE} option.
103Specifying raw target names not wrapped in a generator expression like
104\c{$<TARGET_FILE_NAME:>} is not supported.
105
106When installing a Windows application, it is common to need a
107\l{Using qt.conf}{qt.conf} file when following CMake's default install
108directory 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}.
110The paths in that \c{qt.conf} file will be based on the \c{CMAKE_INSTALL_xxxDIR}
111variables, whose defaults are provided by CMake's \l{GNUInstallDirs} module.
112
113You can override some of those defaults with the parameters in the following
114table, 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
143No \c{qt.conf} file is written if \c{executable} is a macOS app bundle, and
144both \c{GENERATE_QT_CONF} and the \c{..._DIR} options are ignored in that
145case. The directory layout of an app bundle is dictated by Apple's
146requirements, and Qt finds libraries, plugins and resources at those
147conventional locations without a \c{qt.conf}.
148
149More verbose output about the deployment steps can be enabled by providing the
150\c{VERBOSE} option. Alternatively, the \l{QT_ENABLE_VERBOSE_DEPLOYMENT}
151variable can be set in the project before the first \c{find_package(Qt6)} call
152to make deployment output verbose by default.
153
154The \c{qt_deploy_runtime_dependencies()} command overwrites existing files by
155default (some warnings may still be issued). Use the \c{NO_OVERWRITE} option
156to prevent overwriting existing files. Note that this option currently only
157affects macOS and Windows deployments.
158
159By default, if \c{executable} is a macOS app bundle, only Qt plugins and Qt
160libraries that comply with Apple's app store requirements are deployed. The
161\c{NO_APP_STORE_COMPLIANCE} option can be given to disable that constraint.
162
163On platforms other than macOS, Qt translations are automatically deployed. To
164inhibit this behavior, specify \c{NO_TRANSLATIONS}. Use
165\l qt_deploy_translations() to deploy translations
166in a customized way.
167
168For Windows desktop applications, the required runtime files for the compiler
169are also installed by default. To prevent this, specify \c{NO_COMPILER_RUNTIME}.
170
171Since Qt 6.7, you can use \c{DEPLOY_TOOL_OPTIONS} to pass additional options to
172the underlying deployment tool. This only has an effect if the underlying
173deployment tool is either macdeployqt or windeployqt.
174
175On Linux, deploying runtime dependencies is based on CMake's
176\c{file(GET_RUNTIME_DEPENDENCIES)} command. The options \c{PRE_INCLUDE_REGEXES},
177\c{PRE_EXCLUDE_REGEXES}, \c{POST_INCLUDE_REGEXES}, \c{POST_EXCLUDE_REGEXES},
178\c{POST_INCLUDE_FILES}, and \c{POST_EXCLUDE_FILES} are only meaningful in this
179context and are forwarded unaltered to \c{file(GET_RUNTIME_DEPENDENCIES)}. See
180the documentation of that command for details.
181
182On Linux, runtime dependencies that are located in system library directories
183are not deployed by default. If \c{POST_EXCLUDE_REGEXES} is specified, this
184automatic exclusion is not performed.
185
186The default value of \c{POST_EXCLUDE_REGEXES} is constructed from the value of
187\l{QT_DEPLOY_IGNORED_LIB_DIRS}.
188
189\sa qt_generate_deploy_app_script(),
190 qt_deploy_qt_conf(),
191 qt_deploy_qml_imports()
192
193\section1 Controlling deployment of Qt plugins
194
195Qt plugins are automatically deployed into \l QT_DEPLOY_PLUGINS_DIR.
196
197You can turn off plugin deployment with the \c NO_PLUGINS argument.
198
199You can include all plugins of a specific type with the \c INCLUDE_PLUGIN_TYPES
200argument. You can exclude all plugins of a specific type with the \c
201EXCLUDE_PLUGIN_TYPES argument. Both arguments take plugin types, e.g. \c
202imageformats.
203
204You can include or exclude specific plugins with the arguments \c
205INCLUDE_PLUGINS and \c EXCLUDE_PLUGINS. Both arguments take plugin names, for
206example \c qjpeg.
207
208\note Plugin names must not be confused with plugin targets. For example, the \c
209Qt6::QJpegPlugin target's plugin name is \c qjpeg.
210
211\note The arguments \c EXCLUDE_PLUGINS, \c EXCLUDE_PLUGIN_TYPES, \c
212INCLUDE_PLUGINS, and \c INCLUDE_PLUGIN_TYPES only work on Windows and Linux.
213
214\section1 Example
215
216The following example shows how to deploy an application \c{MyApp}.
217
218\include cmake-deploy-runtime-dependencies.qdocinc
219
220The following example shows how to use the \c{DEPLOY_TOOL_OPTIONS} parameter to
221pass different options to macdeployqt and windeployqt.
222
223\include cmake-deploy-runtime-dependencies-deploy-tool-options.qdocinc
224
225*/