Compilers
In CLion, you can use GCC-based compilers, Clang, Clang-cl, Visual Studio C++ compiler, as well as IAR compiler and custom-defined compiler.
The compilers you configure in the currently selected toolchain are used for all the projects you work with in CLion.
tip
By default, CLion detects the compilers from the provided environment (for example, MinGW, Cygwin, or Microsoft Visual C++ on Windows) along with other tools.
Go to Settings | Build, Execution, Deployment | Toolchains and select the toolchain you want to edit.
In the C++ Compiler or C Compiler fields specify the path to the desired installation, for example:
If you need to use non-default compilers, you can change the paths in toolchain settings (IDE-wide) or set the compilers manually, affecting the current project only.
note
In case your project specifies the compilers that differ from those set in the toolchain, CLion will use the project ones.
For CMake projects, you can change the compilers in the CMake profile settings defined per project.
Go to Settings | Build, Execution, Deployment | CMake.
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:After you apply the settings, CLion will reset the CMake cache and reload your project.
Thanks for your feedback!