在此页面上

QML 的 CMake 策略

Qt Qml 提供多种 CMake 策略来控制 QML 相关 CMake 命令的向后兼容性和行为。

可用策略

  • QTP0001- 控制 QML 模块版本行为
  • QTP0004- 控制 QML 模块输出目录结构
  • QTP0005- 控制 QML 类型注册行为

设置策略

使用qt_policy()cmake_policy() 在 CMakeLists.txt 中设置这些策略:

qt_policy(SET QTP0001 NEW)

另请参阅 CMake Integration for QMLqt_add_qml_module

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