###
# Generate gcov html reports with gcovr
# install: pip install gcovr
###
include("${CMAKE_CURRENT_LIST_DIR}/HelperFunctions.txt")
set(COV_EXCLUDE "${CMAKE_SOURCE_DIR}/\(3rdparty|build|include|common|libdi|libdipp|tests\).*")
set(PROJECT_COVERAGE_DIR "${PROJECT_BINARY_DIR}/coverage")
message("-- Code coverage xml/html reports enabled")
file(MAKE_DIRECTORY ${PROJECT_COVERAGE_DIR})
add_custom_target(coverage
DEPENDS coverage-html
DEPENDS coverage-xml
)
add_custom_target(coverage-xml
COMMAND "gcovr" "--xml" "-o" "${PROJECT_COVERAGE_DIR}/coverage.xml" "-r" "${PROJECT_SOURCE_DIR}" "--exclude" "'${COV_EXCLUDE}'" "--object-directory" "${PROJECT_BINARY_DIR}"
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
)
add_custom_target(coverage-html
COMMAND "gcovr" "--html" "--html-details" "-o" "${PROJECT_COVERAGE_DIR}/index.html" "-r" "${PROJECT_SOURCE_DIR}" "--exclude" "'${COV_EXCLUDE}'" "--object-directory" "${PROJECT_BINARY_DIR}"
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
)
di_get_random_port(PORT)
add_custom_target(coverage-http
DEPENDS coverage-html
COMMAND python2 -m SimpleHTTPServer ${PORT}
WORKING_DIRECTORY ${PROJECT_COVERAGE_DIR}
)