CLion 2019.1 Help

Switching Compilers

In CLion, you can use GCC and Clang compilers.

On Windows, the provided environment (Cygwin or MinGW) includes the compilers along with other tools. Also, the Microsoft Visual C++ compiler is supported in experimental mode.

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.

Note: if you specify the compiler in CMake settings, this will override the selection made in the toolchains settings.

Last modified: 12 June 2019

See Also