Open jcbastosportela opened 3 years ago
Hi I am new to UT and trying to use CodeCoverage.cmake but it not generate branch coverage report. Please help for getting branch coverage. Discription- I set up my project 'foo' in the following way. Copied the cmake file from the https://github.com/bilke/cmake-modules/blob/master/CodeCoverage.cmake to a subdirectory 'cmake_modules'. In the CMakeLists.txt file after the add_executable(foo ...) I added the following:
if(CMAKE_COMPILER_IS_GNUCXX) LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake_modules") include(CodeCoverage) APPEND_COVERAGE_COMPILER_FLAGS() set(COVERAGE_LCOV_EXCLUDES 'dir1/' 'dir2/') // this is optional if you want to exclude some directory from the report SETUP_TARGET_FOR_COVERAGE_LCOV(NAME foo_coverage EXECUTABLE foo DEPENDENCIES foo) endif() After cmake, build the target make make foo_coverage And open the report with index.html file in the foo_coverage folder in the build folder
When
set(GCOV_PATH "path to my desired gcov executable")
this path won't be used by
gcovr
. It will instead use whatevergcov
it finds in the system (if it does).