QT_DEPLOY_PLUGINS_DIR
用于在某些目标平台上部署 Qt 插件的前缀相对子目录。
该变量由名为QT_DEPLOY_SUPPORT 的脚本定义。它仅应在安装过程中的部署环节或构建后规则中使用。
注意:这是一个 低级部署 API 变量,仅应用于高级用例,即那些未被更高层级的 API 命令(如qt_generate_deploy_app_script)所涵盖的场景。
该变量于 Qt 6.3 版本中引入。
项目应在部署脚本中使用 `QT_DEPLOY_PLUGINS_DIR `,以避免硬编码用于部署插件的特定目录。
QT_DEPLOY_PLUGINS_DIR 默认值为plugins 。若要更改QT_DEPLOY_PLUGINS_DIR 的值,请在包含QT_DEPLOY_SUPPORT 之前,在项目部署脚本中进行设置。
QT_DEPLOY_PLUGINS_DIR 路径相对于QT_DEPLOY_PREFIX。
在将插件部署到 macOS 应用程序包时,该变量没有实际意义,因此不应在此场景中使用。Apple 的 macOS 应用程序包指南要求所有插件都必须部署到应用程序包内容中的PlugIns 子目录下。
示例
cmake_minimum_required(VERSION 3.16...3.22)
project(MyThings)
# The following CMAKE_INSTALL_*DIR variables are used to initialize their
# QT_DEPLOY_*_DIR counterparts.
set(CMAKE_INSTALL_BINDIR "mybindir")
set(CMAKE_INSTALL_LIBDIR "mylibdir")
set(CMAKE_INSTALL_LIBEXECDIR "mylibexecdir")
find_package(Qt6 REQUIRED COMPONENTS Core)
qt_standard_project_setup()
qt_add_executable(MyApp main.cpp)
set(deploy_script "${CMAKE_CURRENT_BINARY_DIR}/deploy_MyApp.cmake")
file(GENERATE OUTPUT ${deploy_script} CONTENT "
set(QT_DEPLOY_PLUGINS_DIR \"mypluginsdir\")
set(QT_DEPLOY_TRANSLATIONS_DIR \"i18n\")
include(\"${QT_DEPLOY_SUPPORT}\")
qt_deploy_runtime_dependencies(
EXECUTABLE \"\${QT_DEPLOY_BIN_DIR}/$<TARGET_FILE_NAME:MyApp>\"
)")
install(SCRIPT ${deploy_script})另请参阅 QT_DEPLOY_SUPPORT、QT_DEPLOY_PREFIX、QT_DEPLOY_BIN_DIR、QT_DEPLOY_LIBEXEC_DIR、QT_DEPLOY_LIB_DIR、QT_DEPLOY_QML_DIR 以及QT_DEPLOY_TRANSLATIONS_DIR。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.