Compare commits

...

3 Commits

2 changed files with 20 additions and 9 deletions

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project(myx-cmake VERSION 0.4.5 LANGUAGES) project(myx-cmake VERSION 0.4.6 LANGUAGES)
include(GNUInstallDirs) include(GNUInstallDirs)
file(WRITE ${CMAKE_SOURCE_DIR}/MyxCMake/MyxCMakeConfigVersion.cmake file(WRITE ${CMAKE_SOURCE_DIR}/MyxCMake/MyxCMakeConfigVersion.cmake

View File

@ -6,21 +6,32 @@ if(MYX_CMAKE_CODE_COVERAGE)
endif() endif()
function(myx_cmake_code_coverage target) function(myx_cmake_code_coverage target)
if(CMAKE_CXX_COMPILER_IS_GCC AND MYX_CMAKE_CODE_COVERAGE) if(MYX_CMAKE_CODE_COVERAGE)
target_compile_options(${target} PUBLIC "--coverage") if(CMAKE_CXX_COMPILER_IS_GCC)
set_property( target_compile_options(${target} PUBLIC "--coverage")
TARGET ${target} set_property(
APPEND_STRING TARGET ${target}
PROPERTY LINK_FLAGS " --coverage") APPEND_STRING
PROPERTY LINK_FLAGS " --coverage")
endif()
if(CMAKE_CXX_COMPILER_IS_CLANG)
target_compile_options(${target} PUBLIC "-fprofile-instr-generate -fcoverage-mapping")
set_property(
TARGET ${target}
APPEND_STRING
PROPERTY LINK_FLAGS " --coverage")
endif()
if(LCOV_EXE) if(LCOV_EXE)
add_custom_target( add_custom_target(
${target}-coverage ${target}-coverage
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND ${LCOV_EXE} --test-name ${target} --output "${target}.lcov" --capture COMMAND ${LCOV_EXE} --test-name ${target} --output "${target}.lcov" --capture
--exclude "/usr/\\\*" --no-exernal
--exclude "${CMAKE_BINARY_DIR}/\\\*" --base-directory ${CMAKE_SOURCE_DIR}
--directory ${CMAKE_BINARY_DIR}) --directory ${CMAKE_BINARY_DIR})
# --exclude "/usr/\\\*"
# --exclude "${CMAKE_BINARY_DIR}/\\\*"
add_dependencies(${target}-coverage ${target}) add_dependencies(${target}-coverage ${target})
if(GENHTML_EXE) if(GENHTML_EXE)