[CMake] Trouble changing C/C++ compiler, CMake reverts my choice

James Bigler bigler at cs.utah.edu
Fri Sep 7 16:10:34 EDT 2007


> CMake 2.4.7 finds gcc on my machine and everything works fine.  However,
> I also have installed a different version of gcc but when I point CMake
> to it (by changing CMAKE_C_COMPILER and CMAKE_CXX_COMPILER) the change
> is reverted after I do 'configure'.  I'm sure the path is correct.  No
> error message is given.  Both versions of gcc work fine outside of CMake.
> 
> What is going on?

You can't change the compiler after you configure once in a directory.  You need 
to start with an empty directory.

You can set these values through environment variables or on the command line:

export CC=mygcc;export CXX=myg++

or

-DCMAKE_C_COMPILER:STRING=mygcc

James


More information about the CMake mailing list