I’m interested in trying out clang, for its static analysis capabilities. I’m currently working on a project in c++, running on ubuntu 11.04. One problem with clang is that it can’t work with libstdc++ 4.4 unless I patch it. I don’t want to mess with the libstdc++ source for what might be a temporary foray into clang.
The alternative is to use libc++ instead of libstdc++. Unfortunately, I haven’t been able to find help online for using alternative STL implementations from CMake.
What do I write in my CMakeLists.txt file to tell CMake to use libc++?
generally speaking you have to remove the std include from your include path and stop clang from linking with stdlib then you manually include the other libraries as CMake libraries and then you also add the include path.
Do you have libc++ installed?
According to the libcxx homepage libcxx currently isn’t officially supported on linux.
clang is widely argument compatible with gcc thus you should be able to pass
clang -nostdlib -nostdincHowever you don’t necessarily need to build your own libc. You can also build the compiler from sources (trunk) and it will most likely support libstdc++. (I just got it working on Fedora15).
The Getting Started page of clang is a good resource!
The clang binary then resides in
${BLD}/Release/bin/. if you decide to do amake installthey should be copied to/usr/local/bin/.Thus you can then pass CMake the following parameters: