To select the compiler, set CMAKE_C_COMPILER and CMAKE_CXX_COMPILER to a valid compiler name or full path on the command-line using cmake -D.
For example:
cmake -G "Ninja" -D CMAKE_C_COMPILER=gcc-4.2 -D CMAKE_CXX_COMPILER=g++-4.2 path/to/your/source
A preferred approach is to use a tool chain file. See cmake-toolchains.
A toolchain file sets variables such as:
The followng finds the path of your C and C++ compilers:
xcrun -find cc
xcrun -find c++
These should be used for the values of CMAKE_C_COMPILER and CMAKE_CXX_COMPILER.