QTP0005

qt_add_qml_module 的 DEPENDENCIES 参数接受目标值

该策略在 Qt 6.8 中引入。它允许向qt_add_qml_module() DEPENDENCIES,IMPORTS,OPTIONAL_IMPORTSDEFAULT_IMPORTS 传递目标。

启用该策略意味着传递给关键字的参数可以以 TARGET 为前缀,然后被视为目标名称。

该策略的OLD 行为是将 "TARGET 名称 "视为两个 URI:"TARGET "和 "name"。

NEW 该策略的行为是将TARGET 视为关键字,并从接下来的目标中提取 URI。如果TARGET 后面的名称没有命名一个目标,或该目标与 QML 模块不对应,则是一个硬性错误。

NEWOLD 行为中,可以通过附加斜线和版本来指定模块版本。详情请参阅 "声明模块依赖关系"。

如果向DEPENDENCIES 传递的 URI 与目标名称重合,Qt 6.8 会发出警告。使用qt_policy命令将策略明确设置为OLDNEW ,即可抑制警告。

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

另请参阅 qt_policyqt_standard_project_setup()qt_cmake_policiesqt_add_qml_module

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