1
if (CMAKE_BUILD_TYPE MATCHES coverage)
2
set(GCOV_FLAGS "${GCOV_FLAGS} --coverage")
3
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCOV_FLAGS}")
4
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${GCOV_FLAGS}")
5
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GCOV_FLAGS}")
6
set(GCOV_LIBS ${GCOV_LIBS} gcov)
8
find_program(GCOVR_EXECUTABLE gcovr HINTS ${GCOVR_ROOT} "${GCOVR_ROOT}/bin")
9
if (NOT GCOVR_EXECUTABLE)
10
message(STATUS "Gcovr binary was not found, can not generate XML coverage info.")
12
message(STATUS "Gcovr found, can generate XML coverage info.")
13
add_custom_target (coverage-xml
14
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
15
COMMAND "${GCOVR_EXECUTABLE}" --exclude="test.*" -x -r "${CMAKE_SOURCE_DIR}"
16
--object-directory=${CMAKE_BINARY_DIR} -o coverage.xml)
19
find_program(LCOV_EXECUTABLE lcov HINTS ${LCOV_ROOT} "${GCOVR_ROOT}/bin")
20
find_program(GENHTML_EXECUTABLE genhtml HINTS ${GENHTML_ROOT})
21
if (NOT LCOV_EXECUTABLE)
22
message(STATUS "Lcov binary was not found, can not generate HTML coverage info.")
24
if(NOT GENHTML_EXECUTABLE)
25
message(STATUS "Genthml binary not found, can not generate HTML coverage info.")
27
message(STATUS "Lcov and genhtml found, can generate HTML coverage info.")
28
add_custom_target (coverage-html
29
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
30
COMMAND "${CMAKE_CTEST_COMMAND}" --force-new-ctest-process --verbose
31
COMMAND "${LCOV_EXECUTABLE}" --directory ${CMAKE_BINARY_DIR} --capture | ${CMAKE_SOURCE_DIR}/trim-lcov.py > dconf-lcov.info
32
COMMAND LANG=C "${GENHTML_EXECUTABLE}" --prefix ${CMAKE_BINARY_DIR} --output-directory lcov-html --legend --show-details dconf-lcov.info
33
COMMAND ${CMAKE_COMMAND} -E echo ""
34
COMMAND ${CMAKE_COMMAND} -E echo "file://${CMAKE_BINARY_DIR}/lcov-html/index.html"
35
COMMAND ${CMAKE_COMMAND} -E echo "")
36
#COMMAND "${LCOV_EXECUTABLE}" --directory ${CMAKE_BINARY_DIR} --capture --output-file coverage.info --no-checksum
37
#COMMAND "${GENHTML_EXECUTABLE}" --prefix ${CMAKE_BINARY_DIR} --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info
38
#COMMAND ${CMAKE_COMMAND} -E echo "\\#define foo \\\"bar\\\""
45
#$(MAKE) $(AM_MAKEFLAGS) check
46
#lcov --directory $(top_builddir) --capture --test-name dconf | $(top_srcdir)/trim-lcov.py > dconf-lcov.info
47
#LANG=C genhtml --prefix $(top_builddir) --output-directory lcov-html --legend --show-details dconf-lcov.info
49
#@echo " file://$(abs_top_builddir)/lcov-html/index.html"