Add target to generate coverage html pages

Add cmake-options -DBUILD_COVERAGE=ON -DCOVERAGE_GENERATE_HTML=ON
Output will be in build folder under coverage/
This commit is contained in:
Kurt Hindenburg
2023-04-04 20:38:50 -04:00
parent 956493dcbe
commit 31fe671f2c

View File

@@ -28,6 +28,7 @@ if(BUILD_TESTING)
endif()
endif()
### Security concerns about sendText and runCommand dbus methods being public
option(REMOVE_SENDTEXT_RUNCOMMAND_DBUS_METHODS "Konsole: remove sendText and runCommand dbus methods" OFF)
@@ -375,3 +376,19 @@ target_link_libraries(konsolepart
)
install(TARGETS konsolepart DESTINATION ${KDE_INSTALL_PLUGINDIR})
# Add cmake-options -DBUILD_COVERAGE=ON -DCOVERAGE_GENERATE_HTML=ON
if(COVERAGE_GENERATE_HTML)
# find required tools - no error checking
find_program(LCOV lcov REQUIRED)
find_program(GENHTML genhtml REQUIRED)
add_custom_target(coverage
# runs tests to get .gcda files
COMMAND ctest --progress
# generate data
COMMAND ${LCOV} --directory . --capture --output-file coverage.info
# generate report
COMMAND ${GENHTML} --ignore-errors source --demangle-cpp -o coverage coverage.info
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
endif()