Покрытие кода
This commit is contained in:
parent
97ccbf69ac
commit
a51a6fd9e7
31
CMLibCodeCoverage.cmake
Normal file
31
CMLibCodeCoverage.cmake
Normal file
@ -0,0 +1,31 @@
|
||||
function(add_code_coverage)
|
||||
list(GET ARGN 0 _target)
|
||||
|
||||
find_program(LCOV_EXE NAMES lcov)
|
||||
find_program(GENHTML_EXE NAMES genhtml)
|
||||
target_compile_options(_target PUBLIC "--coverage")
|
||||
|
||||
if(LCOV_EXE)
|
||||
add_custom_target(coverage-${_target}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMAND ${LCOV_EXE}
|
||||
--test-name
|
||||
${_target}
|
||||
--output
|
||||
"${_target}.lcov"
|
||||
--capture
|
||||
--directory
|
||||
${CMAKE_BINARY_DIR})
|
||||
add_dependencies(coverage-${_target} ${_target})
|
||||
|
||||
if(GENHTML_EXE)
|
||||
add_custom_target(coverage-report-${_target}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMAND ${GENHTML_EXE}
|
||||
--output-directory
|
||||
"report-${_target}"
|
||||
"${_target}.lcov")
|
||||
add_dependencies(coverage-report-${_target} coverage-${_target})
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
Loading…
Reference in New Issue
Block a user