File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ if (CMAKE_BUILD_TYPE STREQUAL "Coverage" )
2+
3+ # Enable coverage compilation option
4+ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU" )
5+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage" )
6+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage" )
7+ endif ()
8+ if (MSVC )
9+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /coverage" )
10+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /coverage" )
11+ endif ()
12+
13+ # Add custom targets for generating coverage reports
14+ add_custom_target (coverage
15+ COMMAND lcov --capture --directory . --output-file coverage.info
16+ COMMAND lcov --output-file coverage.info --extract coverage.info '*/include/xsf/*'
17+ COMMAND lcov --list coverage.info
18+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
19+ COMMENT "Generating coverage report"
20+ )
21+
22+ # Generate coverage reports in HTML format
23+ add_custom_target (coverage_html
24+ COMMAND genhtml --demangle-cpp --legend coverage.info --output-directory coverage_report
25+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
26+ COMMENT "Generating HTML coverage report"
27+ )
28+ add_dependencies (coverage_html coverage )
29+
30+ endif () # CMAKE_BUILD_TYPE=Coverage
You can’t perform that action at this time.
0 commit comments