Browse Source

Made coverage html output optional.

master
James Goppert 9 years ago
parent
commit
dd8ff8db12
  1. 11
      CMakeLists.txt
  2. 21
      test/CMakeLists.txt

11
CMakeLists.txt

@ -10,14 +10,15 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type" FORCE) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type" FORCE)
message(STATUS "set build type to ${CMAKE_BUILD_TYPE}") message(STATUS "set build type to ${CMAKE_BUILD_TYPE}")
endif() endif()
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
STRINGS "Debug;Release;RelWithDebInfo;MinSizeRel;Profile") STRINGS "Debug;Release;RelWithDebInfo;MinSizeRel;Profile")
option(SUPPORT_STDIOSTREAM option(SUPPORT_STDIOSTREAM
"If enabled provides support for << operator (as used with "If enabled provides support for << operator (as used with std::cout)" OFF)
std::cout)" OFF) option(TESTING "Enable testing" OFF)
option(TESTING "Enable testing" OFF)
option(FORMAT "Enable formatting" OFF) option(FORMAT "Enable formatting" OFF)
option(COV_HTML "Display html for coverage" OFF)
if(SUPPORT_STDIOSTREAM) if(SUPPORT_STDIOSTREAM)
add_definitions(-DSUPPORT_STDIOSTREAM) add_definitions(-DSUPPORT_STDIOSTREAM)
@ -56,8 +57,6 @@ set(CMAKE_CXX_FLAGS
) )
string(REPLACE ";" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REPLACE ";" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
enable_testing()
include_directories(${CMAKE_SOURCE_DIR}) include_directories(${CMAKE_SOURCE_DIR})
file(GLOB_RECURSE COV_SRCS matrix/*.hpp matrix/*.cpp) file(GLOB_RECURSE COV_SRCS matrix/*.hpp matrix/*.cpp)
@ -96,3 +95,5 @@ set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH}) set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
set(CPACK_PACKAGE_CONTACT "james.goppert@gmail.com") set(CPACK_PACKAGE_CONTACT "james.goppert@gmail.com")
include(CPack) include(CPack)
# vim: set noet fenc=utf-8 ft=cmake ff=unix sts=0 sw=4 ts=4 :

21
test/CMakeLists.txt

@ -27,13 +27,30 @@ foreach(test_name ${tests})
endforeach() endforeach()
if (${CMAKE_BUILD_TYPE} STREQUAL "Profile") if (${CMAKE_BUILD_TYPE} STREQUAL "Profile")
add_custom_target(coverage
add_custom_target(coverage_build
COMMAND ${CMAKE_CTEST_COMMAND} COMMAND ${CMAKE_CTEST_COMMAND}
COMMAND lcov --capture --directory . --output-file coverage.info COMMAND lcov --capture --directory . --output-file coverage.info
COMMAND lcov --summary coverage.info COMMAND lcov --summary coverage.info
WORKING_DIRECTORY ${CMAKE_BUILD_DIR}
DEPENDS test_build
)
add_custom_target(coverage_html
COMMAND genhtml coverage.info --output-directory out COMMAND genhtml coverage.info --output-directory out
COMMAND x-www-browser out/index.html COMMAND x-www-browser out/index.html
WORKING_DIRECTORY ${CMAKE_BUILD_DIR} WORKING_DIRECTORY ${CMAKE_BUILD_DIR}
DEPENDS test_build DEPENDS coverage_build
)
set(coverage_deps
coverage_build)
if (COV_HTML)
list(APPEND coverage_deps coverage_html)
endif()
add_custom_target(coverage
DEPENDS ${coverage_deps}
) )
endif() endif()

Loading…
Cancel
Save