Skip to content

Conversation

@jcbastosportela
Copy link

When
set(GCOV_PATH "path to my desired gcov executable")

this path won't be used by gcovr. It will instead use whatever gcov it finds in the system (if it does).

@budhisagar
Copy link

budhisagar commented Jun 29, 2022

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

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants