Skip to content
Snippets Groups Projects
Unverified Commit 87dcef71 authored by Steve Plimpton's avatar Steve Plimpton Committed by GitHub
Browse files

Merge pull request #952 from rbberger/coverage

Add code coverage target to CMake
parents 7e234497 d830fc23
No related branches found
No related tags found
No related merge requests found
...@@ -49,6 +49,11 @@ if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel") ...@@ -49,6 +49,11 @@ if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -restrict") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -restrict")
endif() endif()
option(ENABLE_COVERAGE "Enable code coverage" OFF)
if(ENABLE_COVERAGE)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
endif()
######################################################################## ########################################################################
# User input options # # User input options #
######################################################################## ########################################################################
...@@ -819,9 +824,38 @@ if(ENABLE_TESTING) ...@@ -819,9 +824,38 @@ if(ENABLE_TESTING)
add_test(ShowHelp lmp${LAMMPS_MACHINE} -help) add_test(ShowHelp lmp${LAMMPS_MACHINE} -help)
endif() endif()
################################## ###############################################################################
# Testing
#
# Requires latest gcovr (for GCC 8.1 support):#
# pip install git+https://github.com/gcovr/gcovr.git
###############################################################################
if(ENABLE_COVERAGE)
find_program(GCOVR_BINARY gcovr)
find_package_handle_standard_args(GCOVR DEFAULT_MSG GCOVR_BINARY)
if(GCOVR_FOUND)
get_filename_component(ABSOLUTE_LAMMPS_SOURCE_DIR ${LAMMPS_SOURCE_DIR} ABSOLUTE)
add_custom_target(
gen_coverage_xml
COMMAND ${GCOVR_BINARY} -s -x -r ${ABSOLUTE_LAMMPS_SOURCE_DIR} --object-directory=${CMAKE_BINARY_DIR} -o coverage.xml
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Generating XML Coverage Report..."
)
add_custom_target(
gen_coverage_html
COMMAND ${GCOVR_BINARY} -s --html --html-details -r ${ABSOLUTE_LAMMPS_SOURCE_DIR} --object-directory=${CMAKE_BINARY_DIR} -o coverage.html
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Generating HTML Coverage Report..."
)
endif()
endif()
###############################################################################
# Print package summary # Print package summary
################################## ###############################################################################
foreach(PKG ${DEFAULT_PACKAGES} ${OTHER_PACKAGES} ${ACCEL_PACKAGES}) foreach(PKG ${DEFAULT_PACKAGES} ${OTHER_PACKAGES} ${ACCEL_PACKAGES})
if(PKG_${PKG}) if(PKG_${PKG})
message(STATUS "Building package: ${PKG}") message(STATUS "Building package: ${PKG}")
......
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