Toolchains
Settings | Build, Execution, Deployment | Toolchains
For CMake, Makefile, and compilation database projects in CLion, a toolchain is a set of all the necessary tools required for building and running your application: the CMake executable (CMake projects), the build tool, the C/C++ compilers, the debugger binary, and the working environment.
When you start working with CLion, you already have a default toolchain available. Although you can use it in development, you may also want to adjust the set of tools for the needs of your project (for example, switch to another compiler).
tip
You can have multiple toolchains for one project and switch between them when needed.
Select the kind of project you are working with to learn more:
CLion uses the configured toolchain to build and run your CMake application. After you set up a toolchain, you can select it in CMake profile settings.
CLion uses the selected toolchain when loading Makefile projects. The toolchain also provides the debugger for Native Application configurations.
After configuring a toolchain, you will be able to select it in Settings | Build, Execution, Deployment | Makefile.
CLion uses the selected toolchain for resolving the compilation database project files.
After configuring a toolchain, you will be able to select it in Settings | Build, Execution, Deployment | Compilation Database. Note that Remote toolchains are not supported for compilation database projects.
The selected toolchain provides the environment and the debugger for custom run/debug configurations. See Creating a custom build target.
Go to Settings | Build, Execution, Deployment | Toolchains and click
to add a new toolchain.
WindowsmacOS/LinuxWatch this video for an overview of Windows toolchain options:
Select one of the pre-defined toolchain setups (MinGW, Cygwin, Visual Studio, or WSL), Remote Host, Docker) or configure a custom toolchain (System):
tip
For more information about configuring CLion on Windows, refer to our tutorial.
Remote Host toolchains are described in Remote with local sources. If you are working with a Docker container, refer to Docker toolchain.
On Linux or macOS, choose the type of your toolchain: System for local projects, Remote Host or Docker for remote development.
tip
See Toolchains for general information.
For more information about Remote Host toolchains, refer to Remote with local sources. If you are working with a Docker container, refer to Docker toolchain.
To initialize the toolchain environment via a script, click Add environment and specify the path to the file. See below for more information.
If required, switch from the bundled CMake to a custom CMake installation of your choice.
By default, CLion will use bundled Ninja as the Build Tool. You can specify another build tool of your choice, for example, make.
CLion will attempt to detect the C/C++ compilers.
If you prefer to use custom compilers instead of the detected ones, provide the paths in C Compiler and C++ Compiler. See Switching compilers.
note
If you are using the GNU ARM toolchain, make sure it's presented in your system
PATH
(refer to Embedded development: toolchains and compilers).For the IAR toolchain, specify the compilers as described in IAR toolchain.
Select the Debugger.
On macOS, you can switch between the bundled LLDB (version 19.1.3) and custom GDB.
On Windows, the options include the bundled GDB (version 15.2), custom GDB, and LLDB (version 9.0.0) for MSVC.
Note that custom LLDB is not currently supported.
CLion verifies your choices and notifies you if any of the tools or packages are missing.
When the configuration is completed, click OK to save it.
Instead of setting the environment manually, you can point CLion to an environment file — a shell script that initializes the environment for your project. This is helpful, for example, when you need to initialize compiler variables, add custom ones, or modify the PATH
.
The following environment files are supported:
Windows MinGW and MSVC toolchains — bat files.
Windows Cygwin, Local Linux/macOS, WSL, Docker, and Remote toolchains — shell files.
tip
See Set the fallback shell .
Most frameworks include environment scripts, which you can use right away. See the example of ESP-IDF on macOS. You can also create your own script, for example, when you need to source several environment files: see the example of ESP-IDF on Windows.
note
Toolchain environment affects all steps performed with that particular toolchain, which includes CMake generation, build, and binary launch.
For all toolchains except Docker, environment sourcing only happens once: the first time the toolchain in used in a CMake profile or upon loading a Makefile. For Docker, sourcing happens each time the toolchain is used.
When you make changes to the environment file, CLion re-sources it automatically by default. You can prevent the environment state from being automatically cached by unchecking the Cache environment from environment file based on file modified timestamps option in Settings | Advanced settings. Also, note that resetting CMake invalidates the environment file cache.
In the toolchain settings, click Add environment, then click From file:
In the Environment file field, specify the path to the script:
You will get notifications in case of script loading issues. CLion also checks the script loading time and terminates the execution if it takes too long.
To source the environment file on Linux (local or remote), WSL, and Docker, CLion invokes
source
or.
in default login shell as set in the$SHELL
variable.If
$SHELL
is empty, CLion uses the shell specified in the Fallback shell for sourcing the environment field of the Advanced settings.
Thanks for your feedback!