Currently, I invoke CMake from my build directory as follows:
CXX="/opt/gcc-4.8/bin/g++" cmake ..
to get CMake to use this particular compiler. Otherwise it uses the operating system default compiler.
My PATH has "/opt/gcc-4.8/bin
" in front of everything else. So, instead of prepending the environmental variable is there way to specify in the "`CMakeLists.txt" file to use the default g++ on the path?
CMake honors the setting of the PATH
environment variable, but gives preference to the generic compiler names cc
and c++
. To determine which C compiler will be used by default under UNIX by CMake, run:
$ which cc
To determine the default C++ compiler, run:
$ which c++
If you generate a symbolic link c++
in /opt/gcc-4.8/bin
which points to /opt/gcc-4.8/bin/g++
, CMake should use GCC 4.8 by default.