Skip to content

Commit

Permalink
Disable coverage if unsupported and only define extra targets when ne…
Browse files Browse the repository at this point in the history
…eded.
  • Loading branch information
vrabaud committed Dec 18, 2023
1 parent 1ef1fca commit 6732121
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ if(AVIF_ENABLE_COVERAGE)
else()
# TODO: Add support for other compilers
message(WARNING "libavif: Ignoring request for coverage (AVIF_ENABLE_COVERAGE); only clang is currently supported.")
set(AVIF_ENABLE_COVERAGE OFF)
endif()
endif()

Expand Down
14 changes: 8 additions & 6 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ set(COVERAGE_TARGETS)
# Macro to register a test for coverage. The first argument is the target name.
# Other arguments, like data path, can be added.
macro(register_test_for_coverage TEST_NAME)
add_custom_target(
${TEST_NAME}_coverage
COMMAND ${CMAKE_COMMAND} -E env "LLVM_PROFILE_FILE=${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.profraw"
$<TARGET_FILE:${TEST_NAME}> ${ARGN}
)
list(APPEND COVERAGE_TARGETS ${TEST_NAME})
if(AVIF_ENABLE_COVERAGE)
add_custom_target(
${TEST_NAME}_coverage
COMMAND ${CMAKE_COMMAND} -E env "LLVM_PROFILE_FILE=${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.profraw"
$<TARGET_FILE:${TEST_NAME}> ${ARGN}
)
list(APPEND COVERAGE_TARGETS ${TEST_NAME})
endif()
endmacro()

add_executable(aviftest aviftest.c)
Expand Down

0 comments on commit 6732121

Please sign in to comment.