cmake-modules icon indicating copy to clipboard operation
cmake-modules copied to clipboard

CodeCoverage.cmake - difficulties using it to cover shared libraries rather than the main program

Open jmp75 opened this issue 4 years ago • 1 comments

Using this version of CodeCoverage.cmake.

I wanted to use CodeCoverage.cmake to extract test coverage information in a context where I have a main test executable but want coverage for a shared library it links against.

The functions setup_target_for_coverage_gcovr_blah have an argument BASE_DIRECTORY but whether trying to use relative paths or absolute paths I just could not get it to work as expected. There is/was a bug such that only the main executable can end up in the code coverage report. Even with that fixed, base_directory appears to be relative the cmake build directory rather than the calling cmakelists.txt.

I've implemented something that works with BASE_DIRECTORY relative to the directory of the calling CMakeLists.txt file. The provisional changes are in this commit

I may submit a PR but I am not sure this is the intended behavior. Also it intersects with the pending pull request 51 related to issue #50 and will try to include these changes before a PR.

jmp75 avatar Jul 11 '20 08:07 jmp75

i encounter same problems the BASE_DIRECTORY is not working expectedly. I think the problem is the L212 the if(${Coverage_BASE_DIRECTORY}) should be changed to if(Coverage_BASE_DIRECTORY) Same as L310 and L382

wuzhuobin avatar Jul 22 '20 08:07 wuzhuobin