Generate a custom deployment script.
命令的定义在
核心
组件对于
Qt6
包,可以像这样加载:
find_package(Qt6 REQUIRED COMPONENTS Core)
This command was introduced in Qt 6.5.
qt_generate_deploy_script( OUTPUT_SCRIPT <var> [TARGET target] [NAME script_name] [CONTENT content] )
若
无版本命令
被禁用,使用
qt6_generate_deploy_script()
代替。它支持如此命令的一组相同自变量。
The command generates a script whose full file path will be stored in the variable named by the
OUTPUT_SCRIPT
option. That script is only written at CMake generation time. It is intended to be used with the
install(SCRIPT)
command, which should come after the application's target has been installed using
install(TARGETS)
.
The command takes care of generating a file named suitably for multi-config generators. Necessary includes are added such that Qt's CMake deployment functions and variables are accessible.
The
TARGET
argument specifies the target that will be deployed by the script. This affects the file name of the generated script, unless
NAME
被指定。
The
NAME
argument controls an identifiable portion within the deployment script's automatically generated name. The
NAME
argument defaults to
custom
if neither
NAME
nor
TARGET
are given.
The
CONTENT
argument specifies the code that is written to the deployment script. The content may contain generator expressions.
This command is intended for generating custom deployment scripts that directly call functions of Qt's deployment API. For less complex deployment purposes, it is more convenient to use qt_generate_deploy_app_script() or qt_generate_deploy_qml_app_script() .
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) install(TARGETS MyApp BUNDLE DESTINATION . RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) qt_generate_deploy_script( TARGET MyApp OUTPUT_SCRIPT deploy_script CONTENT " qt_deploy_runtime_dependencies( EXECUTABLE $<TARGET_FILE_NAME:MyApp> ) ") install(SCRIPT ${deploy_script})
另请参阅 qt_generate_deploy_app_script() and qt_generate_deploy_qml_app_script() .