MantisBT - CMake
View Issue Details
0009678CMakeCTestpublic2009-10-07 13:552010-12-14 18:49
Wojciech Migda 
David Cole 
normalmajoralways
closedwon't fix 
CMake-2-6 
 
0009678: CTest fails to summarize code coverage using gcov for files compiled outside PROJECT_SOURCE_DIR subtree
When the unit test binary is linked with a static library compiled from source files located outside the PROJECT_SOURCE_DIR then although the *.gcov files are generated, they are missed out from the final xml file.

The attached example has a following folder structure:

[DIR] code_coverage
  [DIR] dir_A
    [DIR] scr_A
      scr_A.c
    CMakeLists.txt
    test_bar.h
    test_foo.h
  [DIR] src_B
    src_B.c

LastCoverage_*.log from the Testing/Temporary folder contains the an
error of a form:

  Errors:
  Something went wrong. Cannot find file: /home/scr/code_coverage/src_B/src_B.c in source dir: /home/scr/code_coverage/dir_A or binary dir: /home/scr/code_coverage/dir_A

Coverage.xml hen contain data for src_A library, but not for src_B.

If a symbolic link to src_B is created within dir_A then the code coverage will be summarized for src_B as well.

After setting CMAKE_USE_RELATIVE_PATHS to TRUE it is even worse and ctest fails to summarize any coverage.
No tags attached.
related to 0005668closed Bill Hoffman CMake/CTest code coverage support doesn't work for MinGW gcc under Windows 
gz code_coverage.tar.gz (2,137) 2009-10-07 13:55
https://public.kitware.com/Bug/file/2538/code_coverage.tar.gz
Issue History
2009-10-07 13:55Wojciech MigdaNew Issue
2009-10-07 13:55Wojciech MigdaFile Added: code_coverage.tar.gz
2009-10-08 15:35Wojciech MigdaNote Added: 0018047
2009-10-12 14:59David ColeStatusnew => assigned
2009-10-12 14:59David ColeAssigned To => David Cole
2009-10-12 15:00David ColeRelationship addedrelated to 0005668
2009-10-12 15:03David ColeNote Added: 0018063
2009-10-12 15:03David ColeStatusassigned => resolved
2009-10-12 15:03David ColeResolutionopen => won't fix
2010-12-14 18:49David ColeNote Added: 0024081
2010-12-14 18:49David ColeStatusresolved => closed

Notes
(0018047)
Wojciech Migda   
2009-10-08 15:35   
I've checked this issue with 2.8.0 RC2 and it is reproducible too
(0018063)
David Cole   
2009-10-12 15:03   
This behavior is "by design." The files that are reported for code coverage analysis are limited to source files that are located underneath CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR. We exclude others on the principal of not reporting coverage for "system files" -- like STL headers for std::string usage. We figure you do not want those files reported.

If you have a better suggestion for this behavior (base it on a variable, allow certain other directories, some other idea, ...?) then please re-open and suggest how to achieve your goals while still keeping the idea of excluding "system source files" from the coverage data.

Better yet, attach a patch that does what you want!
(0024081)
David Cole   
2010-12-14 18:49   
Closing bugs that have been resolved for more than 3 months without any further updates.