CLion 2020.1 Help

Switching Compilers

In CLion, you can use GCC and Clang compilers.

On Windows, the provided environment (Cygwin, MinGW, or Microsoft Visual C++) includes the compilers along with other tools.

There are two ways of changing the compiler for your CMake project, either in the toolchain settings or in the CMake profile settings. The difference between these two options is in their scope: toolchains are set per IDE, affecting all the projects you work with in CLion, while CMake options are configured for a particular CMake profile defined per project.

Set compiler in the toolchain

  1. Go to Settings / Preferences | Build, Execution, Deployment | Toolchains.

  2. In the C++ Compiler or C Compiler fields specify the path to the desired installation, for example:

    set compiler via toolchain

Set compiler in the CMake profile

  1. Go to Settings / Preferences | Build, Execution, Deployment | CMake.

  2. In the CMake options field, specify the compiler by setting the CMAKE_LANG_COMPILER variable:

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

    The LANG part specifies the language (C for C and CXX for C++), and you need to provide the full path to the compiler, for example:

    st compiler via cmake flag

  3. After you apply the settings, CLion will reset the CMake cache and reload your project.

Last modified: 15 July 2020