How can I change compilers in CLion?

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.



Is there a way to set this as a default setting? So far, I have to set the compiler for every project I create.



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.

Edited by Cja987

Please sign in to leave a comment.

Have more questions?

Submit a request