0

I recently started a C++ class and need to switch my compiler from gcc++ to clang++ in CLion. I assume I need to set my compiler within the CMakeList.txt within my project, but again I am completely new to C++ so any help would be appreciated!

sepp2k
  • 363,768
  • 54
  • 674
  • 675

1 Answers1

0

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.

Or you can do it using CMake Options:

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] (example for gcc compiler:

-D CMAKE_<LANG>_COMPILER=/usr/local/Cellar/gcc@6/bin/6.4.0/g++-6
PaulP1
  • 125
  • 1
  • 7