1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
5\page qt-deploy-runtime-dependencies.html
6\ingroup cmake-commands-qtcore
8\title qt_deploy_runtime_dependencies
9\keyword qt6_deploy_runtime_dependencies
11\summary {Deploy Qt plugins, Qt and non-Qt libraries needed by an executable.}
13\include cmake-find-package-core.qdocinc
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.
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.
27qt_deploy_runtime_dependencies(
29 [ADDITIONAL_EXECUTABLES files...]
30 [ADDITIONAL_LIBRARIES files...]
31 [ADDITIONAL_MODULES files...]
35 [PLUGINS_DIR plugins_dir]
39 [NO_APP_STORE_COMPLIANCE]
42 [PRE_INCLUDE_REGEXES regexes...]
43 [PRE_EXCLUDE_REGEXES regexes...]
44 [POST_INCLUDE_REGEXES regexes...]
45 [POST_EXCLUDE_REGEXES regexes...]
46 [POST_INCLUDE_FILES files...]
47 [POST_EXCLUDE_FILES files...]
53When installing an application, it may be desirable to also install the
54libraries and plugins it depends on. When the application is a macOS app bundle
55or a Windows executable, \c{qt_deploy_runtime_dependencies()} can be called
56from an install-time script to deploy those dependencies. It will install
57non-system Qt libraries plus an appropriate set of Qt plugins.
59On Linux, the command will deploy additional libraries, beyond just those
60related to Qt, that are included with the project. However, when executed on
61macOS or Windows, the command will use either \c macdeployqt or \c windeployqt,
62which will only deploy libraries that are specific to Qt.
64This command only considers runtime dependencies for which linking
65relationships exist in the underlying binaries. It does not deploy QML modules,
66see \l{qt6_deploy_qml_imports}{qt_deploy_qml_imports()} for that.
70The \c{EXECUTABLE} option must be provided.
72The \c{executable} argument should be the path to the executable file in the
73build directory. For example, \c{${CMAKE_CURRENT_BINARY_DIR}/MyApp.exe}, or more
74dynamically \c{$<TARGET_FILE:MyApp>}. Specifying raw target names not wrapped in
75a generator expression like \c{<TARGET_FILE:>} is not supported.
77For macOS app bundles, the \c{executable} argument should be a path to the
78bundle directory, relative to the base install location.
79For example \c{MyApp.app}, or more dynamically
80\c{$<TARGET_FILE_NAME:MyApp>.app}.
81Specifying raw target names not wrapped in a generator epxression like
82\c{<TARGET_FILE_NAME:>} is not supported.
84It may also be desirable to install dependencies for other binaries related to
85the \c{executable}. For example, plugins provided by the project might have
86further dependencies, but because those plugins won't be linked directly to the
87executable, \c{qt_deploy_runtime_dependencies()} won't automatically discover
88them. The \c{ADDITIONAL_EXECUTABLES}, \c{ADDITIONAL_LIBRARIES}, and
89\c{ADDITIONAL_MODULES} options can be used to specify additional binaries
90whose dependencies should also be deployed (installing the named binaries
91themselves is still the project's responsibility). The naming of these keywords
92follows CMake's conventions, so Qt plugins would be specified using
93\c{ADDITIONAL_MODULES}.
94Each value should be a path relative to the base install location. The values
95can use generator expressions, same as with the \c{EXECUTABLE} option.
96Specifying raw target names not wrapped in a generator epxression like
97\c{<TARGET_FILE_NAME:>} is not supported.
99When installing a Windows application, it is common to need a
100\l{Using qt.conf}{qt.conf} file when following CMake's default install
101directory structure. If the \c{GENERATE_QT_CONF} option is given, an appropriate
102\c{qt.conf} file will be written to the same directory as the \c{executable}.
103The paths in that \c{qt.conf} file will be based on the \c{CMAKE_INSTALL_xxxDIR}
104variables, whose defaults are provided by CMake's \l{GNUInstallDirs} module.
105You can override some of those defaults with the \c{BIN_DIR}, \c{LIB_DIR},
106\c{PLUGINS_DIR}, and \c{QML_DIR} options, all of which are expected to be
107relative to the base install location. A \c{qt.conf} file is always written if
108\c{executable} is a macOS app bundle, regardless of whether or not
109\c{GENERATE_QT_CONF} is provided. The \c{..._DIR} options are also ignored in
110that case, since the directory layout of an app bundle is dictated by Apple's
113More verbose output about the deployment steps can be enabled by providing the
114\c{VERBOSE} option. Alternatively, the \l{QT_ENABLE_VERBOSE_DEPLOYMENT}
115variable can be set in the project before the first \c{find_package(Qt6)} call
116to make deployment output verbose by default.
118The \c{qt_deploy_runtime_dependencies()} command overwrites existing files by
119default (some warnings may still be issued). Use the \c{NO_OVERWRITE} option
120to prevent overwriting existing files. Note that this option currently only
121affects macOS and Windows deployments.
123By default, if \c{executable} is a macOS app bundle, only Qt plugins and Qt
124libraries that comply with Apple's app store requirements are deployed. The
125\c{NO_APP_STORE_COMPLIANCE} option can be given to disable that constraint.
127On platforms other than macOS, Qt translations are automatically deployed. To
128inhibit this behavior, specify \c{NO_TRANSLATIONS}. Use
129\l{qt6_deploy_translations}{qt_deploy_translations()} to deploy translations
132For Windows desktop applications, the required runtime files for the compiler
133are also installed by default. To prevent this, specify \c{NO_COMPILER_RUNTIME}.
135On Linux, deploying runtime dependencies is based on CMake's
136\c{file(GET_RUNTIME_DEPENDENCIES)} command. The options \c{PRE_INCLUDE_REGEXES},
137\c{PRE_EXCLUDE_REGEXES}, \c{POST_INCLUDE_REGEXES}, \c{POST_EXCLUDE_REGEXES},
138\c{POST_INCLUDE_FILES}, and \c{POST_EXCLUDE_FILES} are only meaningful in this
139context and are forwarded unaltered to \c{file(GET_RUNTIME_DEPENDENCIES)}. See
140the documentation of that command for details.
142On Linux, runtime dependencies that are located in system library directories
143are not deployed by default. If \c{POST_EXCLUDE_REGEXES} is specified, this
144automatic exclusion is not performed.
146The default value of \c{POST_EXCLUDE_REGEXES} is constructed from the value of
147\l{QT_DEPLOY_IGNORED_LIB_DIRS}.
149\sa {qt6_generate_deploy_app_script}{qt_generate_deploy_app_script()},
150 {qt6_deploy_qt_conf}{qt_deploy_qt_conf()},
151 {qt6_deploy_qml_imports}{qt_deploy_qml_imports()}
155\include cmake-deploy-runtime-dependencies.qdocinc