CMake doesn’t (always) listen to CC
and CXX
. Instead use CMAKE_C_COMPILER
and CMAKE_CXX_COMPILER
:
cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ ...
See also the documentation.
Alternatively, you can provide a toolchain file, but that might be overkill in this case.