CLion 2017.3 Help

How to switch compilers in CLion


CLion supports GCC and Clang compilers. If you are using CLion on Windows, you need to provide CLion with Cygwin and MinGW environments, which include that compilers and other sets of tools. Alternatively, you can use Microsoft Visual C++ compiler. You can install different compilers (and even different versions of any of them) on your system and use the one that is most suitable for a certain project needs. You can do that using one of the following procedures.

Setting up compiler via toolchain

To select a preferred compiler via a toolchain, do the following:

  1. Go to the File | Settings | Build, Execution, Deployment | Toolchains (or CLion | Preferences | Build, Execution, Deployment | Toolchains if you are om macOS).
  2. In the C++ Compiler and C Compiler fields specify the path to the desired installation:
    cl selectGCC

Setting up compiler using CMake options

You can also specify the desired compiler in CMake settings dialog, as follows:

  1. Go to the File | Settings | Build, Execution, Deployment | CMake (or CLion | Preferences | Build, Execution, Deployment | CMake if you are on macOS).
  2. In CMake options field of the dialog, specify a compiler by passing the following string:
    -D CMAKE_<LANG>_COMPILER=[fully qualified compiler name]
    or for our example with GCC:
    cl selectCompilerCMake
  3. Click Apply and OK. Note that these actions clear CMake cache and activate reload of CMake project.
  4. Note, that in this way you will override the selection made in toolchain settings.

To learn more details on toolchains and other important features of CMake configuration, refer to our manual.

Last modified: 27 March 2018