# 编译器

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

在 CLion 中，您可以使用基于 [GCC](https://gcc.gnu.org/) 的编译器、 [Clang](https://clang.llvm.org/)、 [Clang-cl](quick-tutorial-on-configuring-clion-on-windows.html#clang-cl)、 [Visual Studio C++ 编译器](quick-tutorial-on-configuring-clion-on-windows.html#msvc-compiler)，以及 [IAR 编译器](iar-toolchain.html) 和 [自定义定义的编译器](custom-compilers.html)。

## 工具链编译器（整个 IDE 作用域）

您在当前选择的工具链中配置的编译器将用于 CLion 中您处理的所有项目。

> **Tip:**
> 默认情况下，CLion 会从提供的环境中检测编译器（例如，Windows 上的 [MinGW](http://www.mingw.org/)、 [Cygwin](https://www.cygwin.com/) 或 [Microsoft Visual C++](https://visualstudio.microsoft.com/vs/features/cplusplus/)）以及其他工具。

Procedure: 更改工具链编译器

1. 转到  `设置 | 构建、执行、部署 | 工具链`  并选择您想要编辑的工具链。

2. 在   C++ 编译器   或   C 编译器   字段中指定所需安装的路径，例如：

![通过工具链设置编译器](https://resources.jetbrains.com/help/img/idea/2026.3/cl_cmake_switchcompilers_toolchains.png)

## 项目编译器

如果您需要使用非默认的编译器，您可以在工具链设置（整个 IDE 作用域）中更改路径，或者手动设置编译器，仅影响当前项目。

> **Note:**
> 如果您的项目指定的编译器与工具链中设置的编译器不同，CLion 将使用项目中指定的编译器。

### CMake 项目的编译器

对于 [CMake](quick-cmake-tutorial.html) 项目，您可以在每个项目定义的   CMake 配置文件   设置中更改编译器。

Procedure: 更改 CMake 配置文件编译器

1. 转到  `设置 | 构建、执行、部署 | CMake` 。

2. 在   CMake 选项   字段中，通过设置 [CMAKE_LANG_COMPILER](https://cmake.org/cmake/help/v3.10/variable/CMAKE_LANG_COMPILER.html) 变量来指定编译器：

```CMAKE
-D CMAKE_<LANG>_COMPILER=[fully qualified compiler name]

```

`LANG`  部分指定语言（   C   表示 C，   CXX   表示 C++），您需要提供编译器的完整路径，例如：

![通过 CMake 设置设置编译器](https://resources.jetbrains.com/help/img/idea/2026.3/cl_cmake_switchcompilers_flag.png)

3. 应用设置后，CLion 将重置 CMake 缓存并重新加载您的项目。

## See also

### 流程

[Quick CMake Tutorial](quick-cmake-tutorial.html) [Makefile projects support](makefiles-support.html)

### 操作指南

[自定义编译器](custom-compilers.html) [Set compiler flags](cmake-profile.html#compiler-flags)

