QTP0007
在生成的部署脚本中,对转发的参数值进行引号和转义处理。
该策略自 Qt 6.12 起引入。该策略影响qt_generate_deploy_app_script()函数将关键字(例如DEPLOY_TOOL_OPTIONS 、PRE_EXCLUDE_REGEXES 和POST_EXCLUDE_FILES )的值传递给qt_deploy_runtime_dependencies() 时,如何将其写入生成的部署脚本中。
如果策略设置为OLD ,则值将以未加引号的形式写入。当生成的脚本运行时,CMake 会按空格分割每个值,并将其中的反斜杠解释为转义序列。这会导致包含空格、反斜杠或双引号的值出现问题。
如果策略设置为 `NEW`,则每个值都会作为带引号的参数写入,其中反斜杠和双引号会被转义,从而确保该值以不变的形式传递给`qt_deploy_runtime_dependencies()`。
当未设置策略且转发的值包含空格、反斜杠或双引号时,会触发AUTHOR_WARNING ,并出于向后兼容性考虑将值以未加引号的形式写入。不包含这些字符的值不受影响,因此不会针对它们发出警告。
例如,一个包含空格的代码签名标识:
# QTP0007 not set - AUTHOR_WARNING is emitted
qt_generate_deploy_app_script(
TARGET MyApp
OUTPUT_SCRIPT deploy_script
DEPLOY_TOOL_OPTIONS "-codesign=Developer ID Application: Foo"
)该标识会作为多个参数传递给 `macdeployqt `,导致代码签名步骤要么选错标识,要么失败。将策略设置为 `NEW ` 后,该标识将作为单个参数传递:
qt_policy(SET QTP0007 NEW)
qt_generate_deploy_app_script(
TARGET MyApp
OUTPUT_SCRIPT deploy_script
DEPLOY_TOOL_OPTIONS "-codesign=Developer ID Application: Foo"
)请注意,将多个选项放入一个以空格分隔的值中的项目,原本依赖于OLD 的行为来拆分这些选项,而一旦策略设置为NEW ,就必须将它们作为单独的列表元素传递:
# Relies on the \c OLD behavior to split the value into four options.
set(options "-hardened-runtime -timestamp -appstore-compliant -verbose=3")# Correct way to pass options with the \c NEW behavior.
set(options -hardened-runtime -timestamp -appstore-compliant -verbose=3)注意: 策略的OLD 行为 已弃用,未来可能会被移除。
另请参阅 qt_policy()、Qt CMake 策略、qt_generate_deploy_app_script() 以及qt_deploy_runtime_dependencies()。
© 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.