How can I change compilers in CLion? Follow
Starting with CLion 2017.3, go to Settings/Preferences | Build, Execution, Deployment | Toolchains , select the toolchain you'd like to configure (you can use several at a time), change C/C++ compilers path there.
As an alternative or for older CLion versions:
Since CLion relies on CMake build system. To change the compiler used in CLion, use method #2 from the official CMake documentation.
Go to Preferences/Settings | Build, Execution, Deployment | CMake | CMake options and pass the following commands:
-D CMAKE_C_COMPILER=<your_path_to_c_compiler> -D CMAKE_CXX_COMPILER=<your_path_to_cxx_compiler>
The corresponding CMake cache variables will be overwritten.
Also find more details and samples in our Quick CMake Tutorial.
Please sign in to leave a comment.
Is there a way to set this as a default setting? So far, I have to set the compiler for every project I create.
Thanks
This is most likely will come together with this request: https://youtrack.jetbrains.com/issue/CPP-1887
Setting the compiler to an invalid value (in this case "ccache cc") broke everything astonishingly, impressively, and most comprehensively: removing the change, reloading the CMake project, re-creating the entire project, and in fact deleting all the CLion preferences and reinstalling CLion did not fix it. Clearly there's something I've missed, but it's definitely serious business changing this setting, and it doesn't take well to mistakes.
You can set ccache through CMakeLists.txt