[CMake] recommended way to test for msvc/cl ?

Brad King brad.king at kitware.com
Mon Jan 30 10:41:52 EST 2006


Alexander Neundorf wrote:
> There is a variable CMAKE_COMPILER_IS_GNUCC, which is set for gcc. AFAIK 
> there is no CMAKE_COMPILER_IS_MSVC.  
> There are CMAKE_C_COMPILER and CMAKE_GENERATOR_CC, which are probably set 
> to "cl" both for MSVC and nmake Makefiles ? 
>  
> So which test is recommended ? 

We've used

IF("${CMAKE_C_COMPILER}" MATCHES "^cl$")

and this should work for you for now, but...

> Or how about adding a "MSVC" to the list above ? 

There needs to be a whole compiler id step added to do this right.  It 
can probably be integrated with the checks for a working compiler, but 
this has not yet been done.  It's been on my to-do list for a long time.

-Brad


More information about the CMake mailing list