[CMake] Coverage support

Rolf Eike Beer eike at sf-mail.de
Mon Aug 7 06:49:48 EDT 2017


Am 2017-08-07 09:57, schrieb Clément Gregoire:
> Hi,
> I'm a bit stuck when trying to add coverage reports to Cmake (gcov + 
> lcov)
> as I can't figure out what is the best (idiomatic) way to do it.
> So far here are the ways I know of :
> - setting the CMAKE_LANG_FLAGS based on a boolean + scan all files / 
> run
> gcov on it : would like to avoid this
> - same but adding a new build type : seems to be way better but running
> gcov would still be a pain
> - same with a tool chain file for the flags : doesn't sound a good idea
> since coverage should only be ran in debug
> - some library to link with that propagates the flags : not possible
> because link flags are not transient
> - macro that adds the flags / does magic on a per target basis : many
> scripts do this but seems to be a pain to maintain. Also I would rather
> have all my test targets be set up automatically
> - any of the above for flags and Ctest ctest_coverage but all I need 
> are
> the gcov/lcov reports, not the coverage.xml for the dashboard
> - using the command parameter of add_test
> - something I missed?
> 
> I want the setup to be easy and compatible with codecov.io, sadly all 
> the
> script I found are bad, undocumented, or old and using bad practices.

What's wrong with this one: 
https://github.com/codecov/example-cpp11-cmake ?

I use it for both Codecov.io and CDash at the same time, see 
https://github.com/osm2go/osm2go/blob/master/.travis.yml

Eike


More information about the CMake mailing list