-
Notifications
You must be signed in to change notification settings - Fork 2
/
DetectCodeCoverage.cmake
43 lines (33 loc) · 1.59 KB
/
DetectCodeCoverage.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
################################################################################
#
# \file DetectCodeCoverage.cmake
# \copyright 2012-2015 J. Bakosi,
# 2016-2018 Los Alamos National Security, LLC.,
# 2019-2021 Triad National Security, LLC.
# All rights reserved. See the LICENSE file for details.
# \brief Detect prerequesites for code coverage analysis
#
################################################################################
# Attempt to find tools required for code coverage analysis
find_program( GCOV gcov )
find_program( FASTCOV fastcov.py )
find_program( GENHTML genhtml )
find_program( SED sed )
# Code coverage analysis only supported if all prerequisites found and the user
# has requested it via the cmake variable COVERAGE=on.
if ( COVERAGE AND
GCOV AND
FASTCOV AND
GENHTML AND
SED AND
CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
message(STATUS "Code coverage analysis enabled with compiler:${CMAKE_CXX_COMPILER_ID}, gcov:${GCOV}, fastcov:${FASTCOV}, genhtml:${GENHTML}, sed:${SED}")
# Enable code coverage analysis.
SET(CODE_COVERAGE ON)
# Make flag enabling code coverage analysis available in parent cmake scope
MARK_AS_ADVANCED(CODE_COVERAGE)
# Only include code coverage cmake functions if all prerequsites are met
include(CodeCoverage)
else()
message(STATUS "Code coverage analysis disabled. Not all prerequisites found: COVERAGE (must be true):${COVERAGE}, compiler (must be GNU):${CMAKE_CXX_COMPILER_ID}, and the following must be found: gcov:${GCOV}, fastcov:${FASTCOV}, genhtml:${GENHTML}, sed:${SED}")
endif()