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

Philip Lowman philip at yhbt.com
Thu Dec 4 01:37:22 EST 2008


On Wed, Dec 3, 2008 at 9:48 PM, Bill Hoffman <bill.hoffman at kitware.com>wrote:

> This is already done in CMake 2.6.  See Modules/CMakeCCompilerId.c.in, it
> is even better than the above because it works when cross compiling. It does
> not use a try-run, but rather a try-compile, and then it looks for strings
> in the executable that was created.
>
> Anyway, it is already done, and it sets the following variables:
>
> 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.

-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20081204/303cf870/attachment.htm>


More information about the CMake mailing list