There are two ways of changing the compiler for your CMake project, either in the toolchain settings or in the CMake profile settings. The difference between these two options is in their scope: toolchains are set per IDE, affecting all the projects you work with in CLion, while CMake options are configured for a particular CMake profile defined per project.
Set compiler in the toolchain
In the C++ Compiler or C Compiler fields specify the path to the desired installation, for example:
Set compiler in the CMake profile
In the CMake options field, specify the compiler by setting the CMAKE_LANG_COMPILER variable:-D CMAKE_<LANG>_COMPILER=[fully qualified compiler name]
LANGpart 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.