QTP0002

指定 Android 特定路径的目标属性可能包含生成器表达式。

该策略自 Qt 6.6 起引入。它更改了对指定 Android 特定路径的目标属性的处理方式:

此策略的OLD 行为不允许在指定Android特定路径的目标属性中使用生成器表达式,但会将指定的路径隐式转换为有效的JSON字符串。

此策略的“NEW ”行为允许在指定 Android 特定路径的目标属性中使用生成器表达式,但这些表达式必须评估为有效的 JSON 字符串。

如果将策略设置为 OLD,则QT_ANDROID_EXTRA_PLUGINS属性的以下值将转换为有效的 JSON 字符串;但如果策略设置为 NEW,则会导致错误:

set_target_properties(
    QT_ANDROID_EXTRA_PLUGINS "\\path\\to\\MyPlugin.so"
)

如果将上述示例的策略设置为 NEW,则部署设置文件中生成的 JSON 字符串将包含转义符号,而非路径分隔符。

生成器表达式仅在策略设置为 NEW 时受支持,因此 OLD 模式会生成包含以下代码的格式错误的部署设置文件:

set_target_properties(
    QT_ANDROID_EXTRA_PLUGINS "$<TARGET_FILE_DIR:MyPlugin>"
)

该属性值在 OLD 和 NEW 策略下均能按预期工作:

set_target_properties(
    QT_ANDROID_EXTRA_PLUGINS "/path/to/MyPlugin.so"
)

注意: 策略的OLD 行为 已弃用,未来可能会被移除。

另请参阅 qt_policy()和Qt CMake 策略。

© 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.