[CMake] Selecting compiler on Windows platform
Josef Karthauser
joe.karthauser at geomerics.com
Mon Oct 22 05:34:49 EDT 2007
I’m a bit confused, as ever ☺.
I’ve got a number of windows compilers, cl and gcc for instance, and I want to specify which one I want to use.
I can do this using an environment variable thus,
% env CXX=gcc cmake –G’NMake Makefiles’ .
which allows CMakeDetermineCXXCompiler.cmake to override the ‘cl’ default that the NMake generator sets.
However, I’d like to control this from within a CMake file, and this doesn’t appear possible. From what I can see, CMakeDetermineCXXCompiler is loaded and executed prior to the CMakeLists.txt file, which means that I cannot set the compiler internally. Is this true, or is there something I’m not aware of?
What I’d like to do is something like:
CMakeLists.txt:
IF(... some condition ...)
SET(ENV{CXX} “gcc”)
ELSE
SET(ENV{CXX} “cl”)
ENDIF(... some condition ...)
... NORMAL BUILD RULES ...
Should this be possible? If not, I’ll have to wrap the contents of the CMakeLists file with a IF(INNERLOOP) and then call CMake –DINNERLOOP=1 from within the CMakeLists.txt file, after setting the environment variable, which is a bit gnarly.
Joe
More information about the CMake
mailing list