-
Notifications
You must be signed in to change notification settings - Fork 0
/
SetupCodeMetrics.cmake
45 lines (39 loc) · 1.95 KB
/
SetupCodeMetrics.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
44
45
# Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
# other BLT Project Developers. See the top-level COPYRIGHT file for details
#
# SPDX-License-Identifier: (BSD-3-Clause)
#################################################
# Setup code metrics - coverage, profiling, etc
#################################################
########################################
# Enable code coverage via gcov
# Note: Only supported for gnu or clang.
########################################
if (ENABLE_COVERAGE)
##########################################################################
# Setup coverage compiler flags
##########################################################################
# Set the actual flags for coverage in the COVERAGE_FLAGS variable
# Note: For gcc '--coverage' is equivalent to
# '-fprofile-arcs -ftest-coverage' for compiling and '-lgcov' for linking
# Additional flags that might be useful:
# " -fno-inline -fno-inline-small-functions -fno-default-inline"
blt_append_custom_compiler_flag(FLAGS_VAR COVERAGE_FLAGS
DEFAULT " "
GNU "--coverage"
CLANG "--coverage")
SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COVERAGE_FLAGS}" )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_FLAGS}" )
SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${COVERAGE_FLAGS}" )
if(ENABLE_FORTRAN)
SET( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${COVERAGE_FLAGS}" )
endif()
######################################
# Setup Code Coverage Report Targets
######################################
include(${BLT_ROOT_DIR}/cmake/SetupCodeCoverageReports.cmake)
endif()
if (VALGRIND_FOUND)
set(MEMORYCHECK_COMMAND ${VALGRIND_EXECUTABLE} CACHE PATH "")
set(MEMORYCHECK_COMMAND_OPTIONS "--trace-children=yes --leak-check=full" CACHE PATH "")
endif()