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).
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.
Compilation database projects
Custom build targets and applications
The selected toolchain provides the environment and the debugger for custom run/debug configurations. See Creating a custom build target.
Create a toolchain
Go toand click to add a new toolchain.
Watch this video for an overview of Windows toolchain options:
On Linux or macOS, choose the type of your toolchain: System for local projects, Remote Host or Docker for remote development.
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.
Select the Debugger.
On macOS, you can switch between the bundled LLDB (version 15.0.5) and custom GDB.
On Windows, the options include the bundled GDB (version 12.1), 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.
Initializing the toolchain environment via a script
Instead of setting the environment manually, you can point CLion to an environment file - a 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
If you make changes in the script, it will be re-sourced automatically. There is also a feature request for manual script reload.
For the case of the Docker toolchain, sourcing happens each time the toolchain is used.
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.