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.
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
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 argumentBASE_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 callingCMakeLists.txt
file. The provisional changes are in this commitI 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.