]> git.ipfire.org Git - thirdparty/pdns.git/blob - m4/pdns_enable_coverage.m4
Merge pull request #14200 from rgacogne/auth-enable-leak-detection-unit-tests
[thirdparty/pdns.git] / m4 / pdns_enable_coverage.m4
1 AC_DEFUN([PDNS_ENABLE_COVERAGE], [
2 AC_MSG_CHECKING([whether to enable code coverage])
3 AC_ARG_ENABLE([coverage],
4 AS_HELP_STRING([--enable-coverage],
5 [enable code coverage @<:@default=no@:>@]),
6 [enable_coverage=$enableval],
7 [enable_coverage=no]
8 )
9 AC_MSG_RESULT([$enable_coverage])
10
11 AS_IF([test "x$enable_coverage" = "xclang"], [
12 dnl let's see if the clang++ specific format is supported,
13 dnl as it has a much lower overhead and is more accurate,
14 dnl see https://clang.llvm.org/docs/SourceBasedCodeCoverage.html
15 gl_COMPILER_OPTION_IF([-fprofile-instr-generate -fcoverage-mapping], [
16 CFLAGS="$CFLAGS -DCOVERAGE -DCLANG_COVERAGE -fprofile-instr-generate -fcoverage-mapping"
17 CXXFLAGS="$CXXFLAGS -DCOVERAGE -DCLANG_COVERAGE -fprofile-instr-generate -fcoverage-mapping"
18 ], [
19 AC_MSG_ERROR([$CXX does not support gathering coverage data in the clang format])
20 ])
21 ])
22
23 AS_IF([test "x$enable_coverage" = "xyes"], [
24 gl_COMPILER_OPTION_IF([-fprofile-arcs -ftest-coverage], [
25 CFLAGS="$CFLAGS -DCOVERAGE --coverage"
26 CXXFLAGS="$CXXFLAGS -DCOVERAGE --coverage"
27 LDFLAGS="$LDFLAGS --coverage"
28 ], [
29 AC_MSG_ERROR([$CXX does not support gathering coverage data])
30 ])
31 ])
32 ])