MantisBT - CMake
View Issue Details
0005668CMakeCMakepublic2007-09-09 13:552016-06-10 14:30
Trevor Kellaway 
Bill Hoffman 
normalmajoralways
closedmoved 
 
 
0005668: CMake/CTest code coverage support doesn't work for MinGW gcc under Windows
Under Windows MinGW gcc a CTest code coverage generation fails, using 2.4.6 or latest CVS head.

This is because the gcc command line "gcc.exe -fprofile-arcs -ftest-coverage -o CMakeFiles/abc.dir/abc.obj -c M:\gcovtest\abc\abc.c" uses backslashes for the source filename, and these are encoded in the "abc.gcno" filename. When CTest cmCTestCoverageHandler.cxx cmCTestCoverageHandler::ProcessHandler() is searching for the source file it performs a directory compare, but this will fail as the slashes don't match.

There are two solutions to this issue, 1) provide a way to get gcc to be passed forward slashes, 2) Modify the gcov output "File " recovered path slashes via a call to "cmSystemTools::ConvertToUnixSlashes(sourceFile);"

CTest invokes gcov with the "-l" argument, and this seems completely broken by passing in backslashes, I've had to remove the "-l" from CTest to get this to work. This command line:

  gcov.exe -l -o "M:/gcovtest/abc/build2/CMakeFiles/abc.dir"
"M:/gcovtest/abc/build2/CMakeFiles/abc.dir/abc.gcda"

Produces this failure as MinGW gcov is expecting forward slashes:

  File `M:\gcovtest\abc\abc.c'
  Lines executed:100.00% of 3
  M:\gcovtest\abc\abc.c:could not open output file `abc.gcda##M:\gcovtest\abc\abc.c.gcov'

I'm a relative newbie regarding gcov, I thought "-l" was meant to append a header filename to the source filename? Is it even sensible to add "-l" when passing in the ".gcda" as the argument?

Does this work under Cygwin? I can only suggest that "-l" isn't passed, and maybe this is somehow made configurable so it can be turned off.

All these problems stem from the original MinGW gcc compile passing in native Windows backslashes to gcc as the argument; if this could be resolved the other problems would go away.
No tags attached.
related to 0004971closed Bill Hoffman MSYS gcov fails if drive letter case differs 
related to 0004972closed Bill Hoffman Code coverage "Something went wrong" verbose mode reports wrong binary path. 
related to 0009678closed David Cole CTest fails to summarize code coverage using gcov for files compiled outside PROJECT_SOURCE_DIR subtree 
Issue History
2007-09-09 13:55Trevor KellawayNew Issue
2007-10-12 10:02Bill HoffmanStatusnew => assigned
2007-10-12 10:02Bill HoffmanAssigned To => Bill Hoffman
2008-10-09 13:27Bill HoffmanNote Added: 0013813
2008-10-09 14:03Trevor KellawayNote Added: 0013817
2009-10-12 14:51David ColeAssigned ToBill Hoffman => David Cole
2009-10-12 14:56David ColeNote Added: 0018061
2009-10-12 14:56David ColeStatusassigned => resolved
2009-10-12 14:56David ColeResolutionopen => fixed
2009-10-12 14:58David ColeNote Added: 0018062
2009-10-12 14:58David ColeAssigned ToDavid Cole => Bill Hoffman
2009-10-12 14:58David ColeStatusresolved => assigned
2009-10-12 15:00David ColeRelationship addedrelated to 0009678
2009-10-12 15:08David ColeRelationship addedrelated to 0004971
2009-10-12 15:08David ColeRelationship addedrelated to 0004972
2016-06-10 14:27Kitware RobotNote Added: 0041383
2016-06-10 14:27Kitware RobotStatusassigned => resolved
2016-06-10 14:27Kitware RobotResolutionfixed => moved
2016-06-10 14:30Kitware RobotStatusresolved => closed

Notes
(0013813)
Bill Hoffman   
2008-10-09 13:27   
Is this still an issue?
(0013817)
Trevor Kellaway   
2008-10-09 14:03   
Bill,

Yes this is still an issue, but low priority for me as I've had to patch my CTest locally, and can't move to a later version of CMake due to my hacked original implementation supporting cross compiling (which I've not had time to move to the new style in the SVN head).
(0018061)
David Cole   
2009-10-12 14:56   
Fix issue 0005668 - use CollapseFullPath when determining if covered file is within source or binary tree. Allows gcc/gcov coverage analysis using MinGW on Windows.

/cvsroot/CMake/CMake/Source/CTest/cmCTestCoverageHandler.cxx,v <-- cmCTestCoverageHandler.cxx
new revision: 1.76; previous revision: 1.75
(0018062)
David Cole   
2009-10-12 14:58   
Bill,

Merge this one to the CMake-2-8 branch next time you do a release candidate...
(0041383)
Kitware Robot   
2016-06-10 14:27   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.