summaryrefslogtreecommitdiff
path: root/cmake/Modules/EnableCoverage.cmake
blob: 411b7c6c51722618195e663ebb2fcae859e39a02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
# SPDX-FileCopyrightText: 2025 Felix Morgner <felix.morgner@gmail.com>
# SPDX-License-Identifier: LGPL-2.1-only

function(enable_coverage TARGET)
  target_compile_options("${TARGET}" PRIVATE
    "$<$<AND:$<CXX_COMPILER_ID:GNU,Clang>,$<CONFIG:RelWithDebInfo>>:-fcondition-coverage>"
    "$<$<AND:$<CXX_COMPILER_ID:GNU,Clang>,$<CONFIG:RelWithDebInfo>>:--coverage>"
  )
  target_link_libraries("${TARGET}" PRIVATE
    "gcov"
  )
endfunction()