Skip to content
Snippets Groups Projects
Commit b7c59e90 authored by Lars Bilke's avatar Lars Bilke
Browse files

Added option CMake option OGS_COVERAGE.

parent 12ad6ea0
No related branches found
No related tags found
No related merge requests found
......@@ -3,10 +3,10 @@
#####################
# Specify minimum CMake version
cmake_minimum_required(VERSION 2.8.3)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)
# Project name
project( OGS-6 )
PROJECT( OGS-6 )
### CMake includes ###
INCLUDE(scripts/cmake/CheckTypeSizes.cmake)
......@@ -19,6 +19,7 @@ IF(NOT OGS_NO_EXTERNAL_LIBS)
ENDIF() # NOT OGS_NO_EXTERNAL_LIBS
INCLUDE(scripts/cmake/ProjectSetup.cmake)
INCLUDE(scripts/cmake/DocumentationSetup.cmake)
INCLUDE(scripts/cmake/Test.cmake)
###########################################################################
### OGS version information. Adjust these if you release a new version. ###
......@@ -66,6 +67,9 @@ IF (OGS_BUILD_INFO)
ADD_DEFINITIONS (-DOGS_BUILD_INFO)
ENDIF (OGS_BUILD_INFO)
# Code coverage
OPTION(OGS_COVERAGE "Enables code coverage measurements with gcov/lcov." OFF)
# Packaging
OPTION(OGS_PACKAGING "Creating installers / packages" OFF)
OPTION_REQUIRES(OGS_PACKAGING_ZIP "Do you want to package as zip?" OGS_PACKAGING)
......
......@@ -88,3 +88,8 @@ IF(MSVC)
ELSE()
ADD_DEFINITIONS(-DOPENMP_LOOP_TYPE=unsigned)
ENDIF()
# Enable code coverage
IF(OGS_COVERAGE)
INCLUDE(CodeCoverage)
ENDIF()
\ No newline at end of file
IF(OGS_COVERAGE)
SETUP_TARGET_FOR_COVERAGE_COBERTURA(ctest_coverage ctest "ctest_coverage_results" "-j;${PROCESSOR_COUNT}")
ENDIF()
\ No newline at end of file
......@@ -6,7 +6,7 @@
# 1. Copy this file into your cmake modules path
# 2. Add the following line to your CMakeLists.txt:
# INCLUDE(CodeCoverage)
#
#
# 3. Use the function SETUP_TARGET_FOR_COVERAGE to create a custom make target
# which runs your test executable and produces a lcov code coverage report.
#
......@@ -15,7 +15,7 @@
FIND_PROGRAM( GCOV_PATH gcov )
FIND_PROGRAM( LCOV_PATH lcov )
FIND_PROGRAM( GENHTML_PATH genhtml )
FIND_PROGRAM( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/tests)
FIND_PROGRAM( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/scripts/test)
IF(NOT GCOV_PATH)
MESSAGE(FATAL_ERROR "gcov not found! Aborting...")
......@@ -53,23 +53,23 @@ FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname)
# Setup target
ADD_CUSTOM_TARGET(${_targetname}
# Cleanup lcov
${LCOV_PATH} --directory . --zerocounters
# Run tests
COMMAND ${_testrunner} ${ARGV3}
# Capturing lcov counters and generating report
COMMAND ${LCOV_PATH} --directory . --capture --output-file ${_outputname}.info
COMMAND ${LCOV_PATH} --remove ${_outputname}.info 'tests/*' '/usr/*' --output-file ${_outputname}.info.cleaned
COMMAND ${LCOV_PATH} --remove ${_outputname}.info 'tests/*' '/usr/*' 'BaseLib/zlib/*' 'BaseLib/logog/*' 'BaseLib/RapidXML/*' --output-file ${_outputname}.info.cleaned
COMMAND ${GENHTML_PATH} -o ${_outputname} ${_outputname}.info.cleaned
COMMAND ${CMAKE_COMMAND} -E remove ${_outputname}.info ${_outputname}.info.cleaned
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report."
)
# Show info where to find the report
ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD
COMMAND ;
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment