[CMake] Status of clang support?

Mateusz Loskot mateusz at loskot.net
Sun Oct 24 20:38:45 EDT 2010


On 24/10/10 23:00, Ryan Pavlik wrote:
> My best guess would be to check for some Clang-specific defines,
> similar to the platform checks.  Actually, it looks like in the Git
> repository of CMake, there is now some Clang-specific support:
> http://github.com/Kitware/CMake/commit/571dc7489111893355deba710feee5990bce92e4
> I think that this commit is included in 2.8.2.

Ryan,

It's very good to know.

> I've made a note on that commit as to where I think a Clang-specific
> variable might be set.

I've seen, great!

> For now, you might be able to look at the
> value of CMAKE_CXX_COMPILER_ID for a more general solution - it seems
> like that might contain "Clang" if building using Clang.

I'm having access to CMake 2.8.0 at this moment
And, this version sets CMAKE_CXX_COMPILER_ID to GNU, even if
C/C++ compilers set to clang:

cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++

Also, simple test always reports the "gnu".

if("${CMAKE_CXX_COMPILER_ID}" MATCHES "clang")
  message(STATUS "clang")
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
  message(STATUS "gnu")
endif()

I will try 2.8.2 soon.

Thanks for your help!

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org
Member of ACCU, http://accu.org


More information about the CMake mailing list