[CMake] How do you determine what compiler is being used?

Bill Hoffman bill.hoffman at kitware.com
Fri Dec 5 14:26:36 EST 2008


Philip Lowman wrote:

>     CMAKE_C_COMPILER_ID
>     CMAKE_CXX_COMPILER_ID
>     CMAKE_Fortran_COMPILER_ID
> 
> 
> Thanks for adding this Bill.  With the exception of dealing with MinGW 
> or differing versions of MSVC this would seem to be a very good 
> replacement for conditionals like:
> 
> IF(CMAKE_COMPILER_IS_GNUCC)
> IF(MSVC)
> 
> Is this feature here to stay?  The documentation doesn't seem very 
> encouraging. =)
> 
>     * *|CMAKE_<LANG>_COMPILER_ID|*: An internal variable subject to change.
> 
>       This is used in determining the compiler and is subject to change.
> 
OK, so this is not so reliable.  Right now it is even set for MSVC IDE 
builds.   Also, we wanted to be able to change it in the future. 
However, it does seem useful.   We would have to figure out a way to 
drive this from the IDE's to get the correct answers.   It is a 
bootstrapping issue.  Right now for makefiles this is done with an 
execute_process on the compiler.  That would have to be different for 
IDE builds.

-Bill



More information about the CMake mailing list