[CMake] Coverage support

Clément Gregoire lectem at gmail.com
Mon Aug 7 07:06:08 EDT 2017


I usually stop reading Cmakelists.txt as soon as I see this

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -pthread -g -O0
-fprofile-arcs -ftest-coverage")

Also you need to use the SETUP_TARGET_FOR_COVERAGE for every single test
target, which seems to be a difficult to scale on big projects

Le lun. 7 août 2017 à 12:50, Rolf Eike Beer <eike at sf-mail.de> a écrit :

> 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
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170807/0699257a/attachment.html>


More information about the CMake mailing list