[CMake] Using gcov/lcov and valgrind with cmake

Gerhard Gappmeier gerhard.gappmeier at ascolab.com
Fri Nov 5 06:43:53 EDT 2010


Thanks for your answer.

I also made some progress meanwhile.
One reason why coverage didn't work was ccache :-(
Now it basically works, but only when settings the CFLAGS and LDFLAGS
manually in the CMakeLists.txt. I expected this would be done
automatically when using NightlyCoverage...

I prepared a new tutorial with my current state of work and uploaded
it to git at github.com:gergap/helloworld.git

Maybe we can complete this together so that everybody who starts with
cmake/ctest/cpack has a complete but simple example.
What do you think?

What I would like to integrate are the following features:
* Compilation on Windows/Linux, maybe Mac (I can't test that)
* Unit test execution
 - with optional coverage analysis
   integrated lcov html output generation would be great
 - optional valgrind/purify memchecks
* Doxygen API generation
* Package generation for windows (NSIS) and Linux(STGZ, RPM, DEB, ...)
* Automatic build using a git hook
 - Integration with buildbot
 - or with CDash

Am 04.11.2010 19:28, schrieb Ben Boeckel:
> Gerhard Gappmeier <gerhard.gappmeier at ascolab.com> wrote:
>> Hi all,
>>
>> I'm trying to figure out how to use gcov and maybe also lcov with cmake.
>> I know it works using ctest, I've seen that in several wiki entries,
>> but I could not find one single example on how to use it.
>> The wiki only shows the commandline args for GCC, but no cmake examples.
>>
>> I attached a simple hello world project with two tests (ADD_TEST) which work.
>> I tried to add the "ctest_coverage" and "ctest_memcheck" commands but I can't 
>> get them working.
>>
>> Maybe somebody can complete this example.
>>
>> IMO a new section about gcov and valgrind should be added to 
>> http://www.cmake.org/cmake/help/cmake_tutorial.html
>> This would help a lot of people.
> 
> Hi,
> 
> I have a setup for doing something that you might be looking for. In the
> top-level CMakeLists.txt[1], I add some options to build with coverage.
> I also have a couple of macros[2] which make generating testing targets
> much nicer[3].
> 
> These macros do not assume CTest is enabled nor conflict with it. AFAIK
> they are gcov-specific, but another option could be added to use lcov
> instead. Similar with valgrind.
> 
> If you have any questions or suggestions, feel free to ask.
> 
> --Ben
> 
> [1]http://git.benboeckel.net/?p=chasmd.git;a=blob;f=CMakeLists.txt
> [2]http://git.benboeckel.net/?p=chasmd.git;a=blob;f=cmake/test.cmake
> [3]http://git.benboeckel.net/?p=chasmd.git;a=blob;f=test/libchasm/CMakeLists.txt
> 
> _______________________________________________
> 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
> 


-- 
mit freundlichen Grüßen / best regards

*Gerhard Gappmeier*
ascolab GmbH - automation systems communication laboratory
Tel.: +49 9131 691 123
Fax: +49 9131 691 128
Web: http://www.ascolab.com
GPG-Key: http://www.ascolab.com/gpg/gg.asc

--
*ascolab GmbH*
Geschäftsführer: Gerhard Gappmeier, Matthias Damm, Uwe Steinkrauß
Sitz der Gesellschaft: Am Weichselgarten 7 • 91058 Erlangen • Germany
Registernummer: HRB 9360
Registergericht: Amtsgericht Fürth



More information about the CMake mailing list