Чистка функции для покрытия кода

This commit is contained in:
Andrei Astafev 2019-10-08 16:33:29 +03:00
parent abfce824d2
commit d57bbeb634

View File

@ -1,11 +1,12 @@
function(add_code_coverage) function(add_code_coverage)
list(GET ARGN 0 _target) list(GET ARGN 0 _target)
if(CMAKE_CXX_COMPILER_IS_GCC)
find_program(LCOV_EXE NAMES lcov) find_program(LCOV_EXE NAMES lcov)
find_program(GENHTML_EXE NAMES genhtml) find_program(GENHTML_EXE NAMES genhtml)
target_compile_options(${_target} PUBLIC "--coverage") target_compile_options(${_target} PUBLIC "--coverage")
get_target_property(LF ${_target} LINK_FLAGS) get_target_property(LF ${_target} LINK_FLAGS)
list(APPEND LF "--coverage") string(APPEND LF " --coverage")
set_target_properties(${_target} PROPERTIES LINK_FLAGS ${LF}) set_target_properties(${_target} PROPERTIES LINK_FLAGS ${LF})
if(LCOV_EXE) if(LCOV_EXE)
@ -31,4 +32,7 @@ function(add_code_coverage)
add_dependencies(coverage-report-${_target} coverage-${_target}) add_dependencies(coverage-report-${_target} coverage-${_target})
endif() endif()
endif() endif()
else()
message("Only GCC is supported for code coverage")
endif()
endfunction() endfunction()