[CMake] How does cmake find its compiler?

Alexander Neundorf a.neundorf-work at gmx.net
Mon Mar 4 14:30:11 EST 2013


On Monday 04 March 2013, Daniel Russel wrote:
> I'm not very clear on how cmake chooses which compiler it uses by default.
> Specifically, we have a system where a there is an old version of gcc
> installed in the system and then a newer version installed elsewhere, but
> in the PATH (so running g++ or gcc finds the new version). However, cmake
> uses the old version unless we explicitly set the CMAKE_CXX_COMPILER. Is
> this what is supposed to happen? I couldn't find docs on how the default
> compiler is picked. Thanks. --

By default, it searches for a list of known compiler names:
cc, gcc, cl, bcc, xlc, clang
In that order, in PATH.
If you set the CC (or CXX respectively) environment variable, it will use this 
compiler. This is the recommended way how to point cmake to a specific 
compiler.

Alex


More information about the CMake mailing list