Kaynağa Gözat

Coverage added (fixes #24).

main
offa 7 yıl önce
ebeveyn
işleme
974de39fee
2 değiştirilmiş dosya ile 64 ekleme ve 1 silme
  1. +7
    -1
      CMakeLists.txt
  2. +57
    -0
      cmake/Coverage.cmake

+ 7
- 1
CMakeLists.txt Dosyayı Görüntüle

@@ -5,6 +5,8 @@ message(STATUS "~~~ ${PROJECT_NAME} v${PROJECT_VERSION} ~~~")

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
option(UNITTEST "Build Unit Tests" ON)
option(COVERAGE "Enable Coverage" OFF)
message(STATUS "Coverage : ${COVERAGE}")


if( CMAKE_BUILD_TYPE )
@@ -14,6 +16,11 @@ else()
endif()


if( COVERAGE )
include(Coverage)
endif()


add_compile_options(-Wall
-Wextra
-pedantic
@@ -39,7 +46,6 @@ if( UNITTEST )
add_subdirectory("test")
endif()


include(Install)



+ 57
- 0
cmake/Coverage.cmake Dosyayı Görüntüle

@@ -0,0 +1,57 @@

# Find Lcov tools
find_program(LCOV lcov DOC "LCov")
find_program(LCOV_GENHTML genhtml DOC "LCov GenHtml" HINTS ${LCOV}/..)

if( NOT LCOV OR NOT LCOV_GENHTML )
message(SEND_ERROR "LCov tools not found")
endif()


# Files and folders
set(COV_DIR "${CMAKE_BINARY_DIR}/coverage")
set(COV_FILE "${COV_DIR}/${PROJECT_NAME}.info")

if( NOT EXISTS ${COV_DIR} )
file(MAKE_DIRECTORY ${COV_DIR})
endif()


# Compiler flags
set(flag --coverage)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")


set(INPUT_DIR "${CMAKE_SOURCE_DIR}")

# Make targets
add_custom_target(coverage-clean ${CMAKE_COMMAND} -E make_directory ${COV_DIR}
COMMAND ${LCOV}
--directory ${INPUT_DIR}
--zerocounters

WORKING_DIRECTORY ${COV_DIR}
COMMENT "Zerocounter coverage data"
VERBATIM
)

add_custom_target(coverage ${CMAKE_COMMAND} -E make_directory ${COV_DIR}
COMMAND ${LCOV}
--capture
--directory ${INPUT_DIR}
--output-file ${COV_FILE}
--no-external

COMMAND ${LCOV}
--remove ${COV_FILE} "*/test/*"
--remove ${COV_FILE} "*/generated/*"
--output-file ${COV_FILE}

COMMAND ${LCOV_GENHTML} --legend ${COV_FILE}

WORKING_DIRECTORY ${COV_DIR}
COMMENT "Generate coverage data"
VERBATIM
)


Yükleniyor…
İptal
Kaydet