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:
- Go to the (or if you are om macOS).
- In the C++ Compiler and C Compiler fields specify the path to the desired installation:
Setting up compiler using CMake options
You can also specify the desired compiler in CMake settings dialog, as follows:
- Go to the (or if you are on macOS).
- In CMake options field of the dialog, specify a compiler by passing the following string: or for our example with GCC:
-D CMAKE_<LANG>_COMPILER=[fully qualified compiler name]
- Click Apply and OK. Note that these actions clear CMake cache and activate reload of CMake project.
- 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.