bilke / cmake-modules

Additional CMake functionality. Most of the modules are from Ryan Pavlik (https://github.com/rpavlik/cmake-modules)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I am trying to use CodeCoverage and failing

chrisfair opened this issue · comments

CMakeLists.txt

I am having the following error...

make Unit_Tests_coverage
[ 90%] Built target Unit_Tests
[100%] Resetting code coverage counters to zero.
Processing code coverage counters and generating report.
Deleting all .da files in . and subdirectories
Done.
Not enough data for a trend yet.

Not enough data for a trend yet.

slope is 10
Improving weather on the way!

slope is 10
Improving weather on the way!

slope is 10
Improving weather on the way!

===============================================================================
All tests passed (2 assertions in 1 test case)

Capturing coverage data from .
Found gcov version: 6.3.1
Scanning . for .gcda files ...
geninfo: WARNING: no .gcda files found in . - skipping!
Finished .info-file creation
Reading tracefile /home/cfair/Tutorial/DesignPatterns/weatherStation/build/coverage.info
lcov: ERROR: no valid records found in tracefile /home/cfair/Tutorial/DesignPatterns/weatherStation/build/coverage.info
make[3]: *** [CMakeFiles/Unit_Tests_coverage.dir/build.make:62: CMakeFiles/Unit_Tests_coverage] Error 255
make[2]: *** [CMakeFiles/Makefile2:105: CMakeFiles/Unit_Tests_coverage.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:112: CMakeFiles/Unit_Tests_coverage.dir/rule] Error 2
make: *** [Makefile:142: Unit_Tests_coverage] Error 2

I can tell the gcda files are not being created....but they have SOMETIMES been created but mostly I get this error. Is this a bug? Or a screw up on my part? Have mercy on my poor CMakeTest file I am just now learning cmake.

I think you are missing SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") (it is described in the usage documentation).

You need the following:

include(CodeCoverage)
APPEND_COVERAGE_COMPILER_FLAGS() 
SETUP_TARGET_FOR_COVERAGE(NAME "somename" EXECUTABLE "someexec")