[CMake] Status of clang support?

Ryan Pavlik rpavlik at iastate.edu
Sun Oct 24 18:00:34 EDT 2010


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.

I've made a note on that commit as to where I think a Clang-specific
variable might be set.  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.

Hope this helps!

Ryan

On Sun, Oct 24, 2010 at 4:09 PM, Mateusz Loskot <mateusz at loskot.net> wrote:
> 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
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>



-- 
Ryan Pavlik
HCI Graduate Student
Virtual Reality Applications Center
Iowa State University

rpavlik at iastate.edu
http://academic.cleardefinition.com
Internal VRAC/HCI Site: http://tinyurl.com/rpavlik


More information about the CMake mailing list