编辑 CMake 配置文件

要打开 CMakeLists.txt 文件进行编辑,请在Projects 视图中右键单击该文件,然后选择Open With >CMake Editor

您也可以使用定位器中的cmo 过滤器,在编辑器中打开当前运行配置的 CMakeLists.txt 文件。这与选择Build >Build for Run Configuration 时的构建目标相同。

支持以下功能:

  • 当光标位于一个文件上时按F2
    • 文件名 - 打开文件
    • CMake 函数、宏、选项、目标、CMake 查找或包含模块、由setlist 创建的局部变量或软件包 - 转到该项目
  • 关键词补全
  • 本地函数和变量、缓存变量、ENV 、目标、包和find_package 添加的变量的代码自动补全
  • 预设代码片段,用于设置 CMake 打印属性和变量,以及创建 Qt GUI 控制台和图形用户界面应用程序和 Find 模块示例
  • 路径补全
  • 自动缩进
  • 匹配括号和引号

问题中显示警告和错误。

安装缺失的 Qt 软件包

如果你在find_package 中添加了一个未安装的 Qt 模块,Qt Creator 会询问你是否要用Qt Online Installer 安装。

安装缺失的 Qt 软件包

选择Yes 即可通过Qt Online Installer 安装该软件包。

另请参阅 "如何:使用 CMake 构建"、"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.