Prefix-relative subdirectory for deploying runtime binaries on some target platforms.
This variable is defined by the script named by QT_DEPLOY_SUPPORT . It should only be used as part of deployment during installation or a post-build rule.
注意: This is a low-level deployment API variable, and should only be used in advanced use-cases that are not covered by the higher-level API commands, like qt_generate_deploy_app_script .
This variable was introduced in Qt 6.3.
Projects should use
QT_DEPLOY_BIN_DIR
in their deploy scripts to avoid hard-coding a particular directory in which to deploy the following types of binaries:
QT_DEPLOY_BIN_DIR
defaults to the value of
${CMAKE_INSTALL_BINDIR}
(usually
bin
), which is provided by CMake's
GNUInstallDirs
module. To change the value of
QT_DEPLOY_BIN_DIR
, ensure that the project sets
CMAKE_INSTALL_BINDIR
先于
核心
package is found.
The
QT_DEPLOY_BIN_DIR
path is relative to
QT_DEPLOY_PREFIX
.
This variable is not meaningful when deploying into a macOS app bundle and should not be used for that scenario.
cmake_minimum_required(VERSION 3.16...3.22)
project(MyThings)
find_package(Qt6 REQUIRED COMPONENTS Core)
qt_standard_project_setup()
qt_add_executable(MyApp main.cpp)
set_target_properties(MyApp PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
# App bundles on macOS have an .app suffix
if(APPLE)
set(executable_path "$<TARGET_FILE_NAME:MyApp>.app")
else()
set(executable_path "\${QT_DEPLOY_BIN_DIR}/$<TARGET_FILE_NAME:MyApp>")
endif()
# Helper app, not necessarily built as part of this project.
qt_add_executable(HelperApp helper.cpp)
set(helper_app_path "\${QT_DEPLOY_BIN_DIR}/$<TARGET_FILE_NAME:HelperApp>")
# Generate a deployment script to be executed at install time
qt_generate_deploy_script(
TARGET MyApp
OUTPUT_SCRIPT deploy_script
CONTENT "
qt_deploy_runtime_dependencies(
EXECUTABLE \"${executable_path}\"
ADDITIONAL_EXECUTABLES \"${helper_app_path}\"
GENERATE_QT_CONF
VERBOSE
)")
# Omitting RUNTIME DESTINATION will install a non-bundle target to CMAKE_INSTALL_BINDIR,
# which coincides with the default value of QT_DEPLOY_BIN_DIR used above, './bin'.
# Installing macOS bundles always requires an explicit BUNDLE DESTINATION option.
install(TARGETS MyApp HelperApp # Install to CMAKE_INSTALL_PREFIX/bin/MyApp.exe
# and ./binHelperApp.exe
BUNDLE DESTINATION . # Install to CMAKE_INSTALL_PREFIX/MyApp.app/Contents/MacOS/MyApp
)
install(SCRIPT ${deploy_script}) # Add its runtime dependencies
另请参阅 QT_DEPLOY_SUPPORT , QT_DEPLOY_PREFIX , QT_DEPLOY_LIBEXEC_DIR , QT_DEPLOY_LIB_DIR , QT_DEPLOY_PLUGINS_DIR , QT_DEPLOY_QML_DIR ,和 QT_DEPLOY_TRANSLATIONS_DIR .