I have setup gcovr to get code coverage on my c++ project which is quite complex in terms of hierarchy of nested static libraries.
One approach I tried was to include required compile options (-fprofile-instr-generate -fcoverage-mapping -fPIC -fprofile-arcs -ftest-coverage
) and link target libraries flags (-fprofile-instr-generate
) on the target for which coverage is supposed to be calculated. But this doesn't include the code from child static library.
To resolve that I added the flags to children static library which worked but this doesn't work for grandchildren & later on.
How can I setup the cMake correctly to get code coverage for all the classes irrespective of their library position?