[CMake] Status of clang support?

Mateusz Loskot mateusz at loskot.net
Sun Oct 24 17:09:19 EDT 2010


On 24/10/10 20:07, Marcus D. Hanwell wrote:
> On Sun, Oct 24, 2010 at 2:58 PM, Michael Wild wrote:
>> On 24. Oct, 2010, at 17:33 , Mateusz Loskot wrote:
>> 
>>> I'm trying to find out what's the status of clang support in
>>> CMake. What version of CMake is recommended to make proper use of
>>> clang 2.8+ for building a C++ software, etc.
>>> 
>>> Feeding the favourite search engine with this:
>>> 
>>> clang site:http://www.cmake.org/pipermail/cmake/
>>> 
>>> gives me literally 4 pages os results, but no announcement-like
>>> posts.
>> 
>> 
>> Hi
>> 
>> Clang's UI is a clone of gcc's, so there's very little extra work
>> CMake has to perform. For me it works flawlessly. I don't know
>> about the earliest version to support Clang, but AFAIK 2.8 works
>> well.
> 
>
> I echo Michael's reports, setting it as the compiler just works for 
> many projects. The ones where it fails it is a compilation issue,
> and I have used CMake 2.8.2 with several projects to test out the
> Clang support.

Michael, Marcus,

Thanks for the confirmation.

I have tried clang 2.8 with one of my projects powered by CMake
and it works well indeed.

Although, I'm curious how to interpret the following messages:

-- The C compiler identification is GNU
-- The CXX compiler identification is GNU

Apparently, clang is identified:

-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ -- works

Also, how can I distinguish clang in CMakeLists.txt to perform
some conditional settings?

if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)

elseif(MSVC)

elseif(CLANG) # ???

endif()

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