How to get the default compiler of c++ on Mac os x
I don't think Mac come with a C/C++ compiler by default anymore. I recommend that you install XCode and XCode commandline tools from the App Store. That will give you the gcc compiler (and probably LLVM as well).

Without knowing your build process, I can't tell you how to set a default compiler. There will be an option in XCode as well as options with command-line build tools. IOW, Macs do not have a system-wide default compiler setting that I'm aware of.

Here's the official documentation on how to use a different compiler with CMake.
https://gitlab.kitware.com/cmake/community/wikis/FAQ#how-do-i-use-a-different-compiler