I'm using CMake with my project and set up a cdash server for continuous/nightly building. Everything works well and by setting up a crontab, we have hourly/nightly build/test results uploaded to our cdash server automatically.
My next step is to add test coverage report to the build. I find the document here http://www.cmake.org/Wiki/CTest:Coverage but frankly it's a bit far from a practical guide.
Currently I've added the required flag (instead of -fprofile-arcs -ftest-coverage
, I find --coverage
better), the compilation process generates .gcno files. But then I'm stuck. The command
make NightlyCoverage
doesn't seem to do anything. Could anybody tell me what is the next to do? The result that I want, is by doing make NightlyCoverage
, coverage reports are generated and uploaded to cdash server.
I have an ugly method to use
gcovr
to make a GCC Code Coverage Report without theCodeCoverage.cmake
: move all*.gcno
and*.gcda
files to project root directory and then rungcovr
I set up my project 'foo' in the following way. Copied the cmake file from the https://github.com/bilke/cmake-modules/blob/master/CodeCoverage.cmake to a subdirectory 'cmake_modules'. In the CMakeLists.txt file after the
add_executable(foo ...)
I added the following:After cmake, build the target make make foo_coverage And open the report with index.html file in the foo_coverage folder in the build folder
I've been using https://github.com/bilke/cmake-modules/blob/master/CodeCoverage.cmake successfully.
Just followed the guidelines: added the files to my
CMAKE_MODULE_PATH
directory, addedin my
CMakeLists.txt
. I also added manuallygcov
as a dependency for my target:With this, I just type
and I get the html report in the
coverage
directory of my build tree.