格式化 CMake 文件
您可以使用cmake-format工具和本地.cmake-format
、.py
或.json
配置文件来格式化 CMake 文件中的任何文本,而无需用一对栅栏来防护。您必须安装该工具,并告知Qt Creator 安装位置。
保存文件时自动格式化 CMake 文件:
- 选择首选项>CMake >Formatter 。
- 在CMakeFormat command 中,输入
cmake-format.exe
的路径。 - 选择Automatic formatting on file save 以在保存 CMake 文件时自动格式化它们。
- 在Restrict to MIME types 中,添加要格式化的文件的 MIME 类型,用分号分隔。默认值为
text/x-cmake
格式化 CMake 文件。如果该字段为空,所有文件都会被格式化。 - 选择Restrict to files contained in the current project 复选框,只格式化属于当前项目的 CMake 文件。
另请参阅 "如何:使用 CMake 构建"、"编辑 MIME 类型"和"CMake"。
Copyright © The Qt Company Ltd. and other contributors. 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.