# 加载/重新加载 CMake

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/zh-cn/help/clion/llms.txt).

Procedure: 加载 CMake

* 当在项目根目录下检测到一个  `CMakeLists.txt`  文件时，CLion 会自动加载它。

要手动加载一个  `CMakeLists.txt`  文件，请在项目树中右键点击它，然后从上下文菜单中选择   加载 CMake 项目  ：

![加载现有的 CMakeLists.txt 文件](https://resources.jetbrains.com/help/img/idea/2026.3/cl_CMake_select_load.png)

Procedure: 在 CMakeLists.txt 中更改时重新加载 CMake

* 默认情况下，当您对  `CMakeLists.txt`  文件进行更改时，CLion 会显示一个浮动通知，指示项目需要重新加载：

![CMake 重新加载浮动通知](https://resources.jetbrains.com/help/img/idea/2026.3/cl_cmake_reload_floating.png)

点击它或按快捷键重新加载 CMake。

* 您可以在  `设置 | 高级设置 | CMake`  中禁用浮动通知：

![高级设置 CMake 浮动通知](https://resources.jetbrains.com/help/img/idea/2026.3/cl_cmake_advancedsettings_reload_floating.png)

在这种情况下，通知将如下所示，建议两种项目重新加载选项：

![CMake 重新加载选项](https://resources.jetbrains.com/help/img/idea/2026.3/cl_reload_cmake.png)

* 重新加载更改 在这种情况下，重新加载项目一次，之后对 `CMakeLists.txt` 的所有更改也需要重新加载。

* 启用自动重新加载 此选项可让 CLion 在每次更改 `CMakeLists.txt` 时静默重新加载项目。 这类似于在 `设置 | 构建、执行、部署 | CMake` 中选择 在编辑 CMakeLists.txt 或其他 CMake 配置文件时重新加载 CMake 项目 复选框： ![在 CMake 设置中启用自动重新加载](https://resources.jetbrains.com/help/img/idea/2026.3/cl_cmake_autoreloadsetting.png) 请注意，当 [重置 CMake 缓存](cmake-cache.html#reset-cache)时，项目会自动重新加载。

Procedure: 禁用 CMake 自动重新加载

* 要完全禁用包括外部更改在内的自动重新加载，请转到  `设置 | 高级设置`  并设置   不要自动触发 CMake 重新加载   复选框：

![禁用 CMake 重新加载](https://resources.jetbrains.com/help/img/idea/2026.3/cl_cmake_advancedsettings_reload.png)

Procedure: 手动重新加载 CMake

在需要时手动重新加载项目，请使用以下选项之一：

* 调用   查找操作  （ `Ctrl+Shift+A` (Windows), `⌘ ⇧ A` (macOS), `⌘ ⇧ A` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ P` (macOS System Shortcuts), `Ctrl+Shift+A` (XWin), `Ctrl+Shift+A` (GNOME), `Ctrl+Shift+A` (KDE), `Escape, X` (Emacs), `Ctrl+Shift+P` (Sublime Text), `⌘ ⇧ P` (Sublime Text (macOS)), `⌘ ⇧ A` (Xcode), `Ctrl+Shift+A` (Visual Studio), `⌘ ⇧ A` (Visual Studio (macOS)), `Ctrl+Shift+A` (ReSharper), `⌘ ⇧ A` (ReSharper (macOS)), `Ctrl+Shift+A` (QtCreator), `⌘ ⇧ A` (QtCreator (macOS)), `Ctrl+I` (NetBeans), `Ctrl+Shift+A` (Eclipse), `⌘ 3` (Eclipse (macOS))）并开始输入  reload cmake 。 请选择 ![](https://resources.jetbrains.com/help/img/idea/2026.3/app.actions.refresh.svg)   重新加载 CMake 项目   操作。

* 在主菜单中，前往  `文件 | ![](https://resources.jetbrains.com/help/img/idea/2026.3/app.actions.refresh.svg) 重新加载 CMake 项目` 或  `工具 | CMake | ![](https://resources.jetbrains.com/help/img/idea/2026.3/app.actions.refresh.svg) 重新加载 CMake 项目` 。

* 在 [CMake 工具窗口](cmake.html) 中，点击 ![](https://resources.jetbrains.com/help/img/idea/2026.3/app.actions.refresh.svg)。

> **Tip:**
> 您还可以 [分配快捷键](configuring-keyboard-and-mouse-shortcuts.html#add-keyboard-shortcut)，用于  重新加载 CMake 项目  操作（在  `设置 | 键位图`  中）

Procedure: 停止项目重新加载

要停止项目重新加载的过程，请使用以下选项之一：

1. 调用   查找操作  （ `Ctrl+Shift+A` (Windows), `⌘ ⇧ A` (macOS), `⌘ ⇧ A` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ P` (macOS System Shortcuts), `Ctrl+Shift+A` (XWin), `Ctrl+Shift+A` (GNOME), `Ctrl+Shift+A` (KDE), `Escape, X` (Emacs), `Ctrl+Shift+P` (Sublime Text), `⌘ ⇧ P` (Sublime Text (macOS)), `⌘ ⇧ A` (Xcode), `Ctrl+Shift+A` (Visual Studio), `⌘ ⇧ A` (Visual Studio (macOS)), `Ctrl+Shift+A` (ReSharper), `⌘ ⇧ A` (ReSharper (macOS)), `Ctrl+Shift+A` (QtCreator), `⌘ ⇧ A` (QtCreator (macOS)), `Ctrl+I` (NetBeans), `Ctrl+Shift+A` (Eclipse), `⌘ 3` (Eclipse (macOS))）并开始输入  stop cmake 。 选择   ![](https://resources.jetbrains.com/help/img/idea/2026.3/app.actions.suspend.svg) 停止 CMake 项目重新加载   操作。

2. 在 [CMake 工具窗口](cmake.html) 中，点击 ![](https://resources.jetbrains.com/help/img/idea/2026.3/app.actions.suspend.svg)。

> **Tip:**
> 您还可以 [分配快捷键](configuring-keyboard-and-mouse-shortcuts.html#add-keyboard-shortcut)，用于  停止 CMake 项目重新加载  操作（在  `设置 | 键位图`  中）

Procedure: 在项目重新加载时管理运行/调试配置

添加或删除目标并重新加载项目时，CLion 会自动创建或删除相应的 [运行/调试配置](run-debug-configuration-application.html)。

您可以在  `设置 | 高级设置`  中控制此行为：

![自动为目标创建或删除配置](https://resources.jetbrains.com/help/img/idea/2026.3/cl_cmake_targets_conftemplates.png)

Procedure: 卸载 CMake

当需要将项目与 CMake 构建系统完全解除链接，或者 CLion 加载了一个  `CMakeLists.txt`  脚本，但想为项目使用另一个脚本时，请使用   卸载 CMake 项目   操作。

* 从主菜单调用  `工具 | CMake | 卸载 CMake 项目` 。

![主菜单中的卸载 CMake 选项](https://resources.jetbrains.com/help/img/idea/2026.3/cl_SelectUnloadCmake.png)

执行此操作后，您的项目状态如 [加载 CMake](#CMakeNotDetected) 中所述。

## See also

### 操作指南

[快速 CMake 教程](quick-cmake-tutorial.html) [CMakeLists.txt](cmakelists-txt-file.html) [CMake 性能分析](cmake-profiling.html)

### 参考

[CMake](cmake0.html)

