[CMake] Coverage support

Clément Gregoire lectem at gmail.com
Mon Aug 7 05:57:49 EDT 2017


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.

Any help is welcome!

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170807/5c2a339f/attachment.html>


More information about the CMake mailing list