[CMake] Problems with coverage on OS X Server

P. Martin mrsmiley98 at lycos.com
Sun Mar 25 14:45:15 EDT 2012


Check your SDK version if you are on Lion or Mt. Lion.
On 10.8, Mt. Lion, you should be using XCode-4.4.
For Lion 10.7.3, this is what I have as of March 25, 2012:

$ xcodebuild -version
Xcode 4.3.2
Build version 4E2002

gcov (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)
Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)

If you build llvm from llvm.org head, you will get llvm-cov,
$ /usr/local/bin/llvm-cov --version
LLVM (http://llvm.org/):
  LLVM version 3.1svn
  Optimized build with assertions.
  Built Mar 23 2012 (21:05:05).
  Default target: x86_64-apple-darwin11.3.0
  Host CPU: corei7


To compile dlrdave-SmallAndFast using clang for coverage:

export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
export CFLAGS='-O0 --coverage'
export CXXFLAGS='-O0 --coverage'
mkdir build
cd build
cmake -DCMAKE_VERBOSE_MAKEFILE=ON ..
make
./echoargs
gcov -o CMakeFiles/echoargs.dir/echoargs.c.gcda ../echoargs.c
llvm-cov -gcda=CMakeFiles/echoargs.dir/echoargs.c.gcda -gcno=CMakeFiles/echoargs.dir/echoargs.c.gcno 


I probably got this all wrong, but there it is.  Some notes:
  It didn't like my -march=native for a cflag with clang.
  I couldn't try compile the simple test with clang HEAD --coverage,
    due to missing symbols for x86_64, which is annoying:
    error log =>  https://gist.github.com/2198932
  It didn't work with llvm-gcc-4.2.1 (2336.9) even if I added a
     target_link_library(echoargs /usr/lib/libprofile_rt.a)

I guess there's a bug in that version of llvm-gcc, but ttwagos. I'm a n00b.


More information about the CMake mailing list