From 7cdaaa09095e9266dee21314599a9258db53685e Mon Sep 17 00:00:00 2001 From: Marcin Serwin Date: Wed, 18 Feb 2026 18:57:07 +0100 Subject: CMake: Don't add coverage tests if gcov is not found. --- test/CMakeLists.txt | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'test') diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 61da30d6..b2b6b074 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -92,25 +92,27 @@ if(ZLIB_BUILD_STATIC) set(llvm_option "gcov") endif(${CMAKE_C_COMPILER_ID} STREQUAL "Clang") - add_executable(infcover infcover.c) - target_link_libraries(infcover ZLIB::ZLIBSTATIC) - target_compile_options(infcover PRIVATE -coverage) - target_link_options(infcover PRIVATE -coverage) - target_compile_definitions( - infcover PRIVATE $<$:HAVE_HIDDEN>) - add_test(NAME zlib_coverage COMMAND infcover) - set(INFCOVER_DIR ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/infcover.dir) - add_test( - NAME zlib_coverage-summary - COMMAND - ${GCOV_EXECUTABLE} ${llvm_option} - ${CMAKE_CURRENT_SOURCE_DIR}/infcover.c -o - ${INFCOVER_DIR}/infcover.c.gcda) - set_tests_properties(zlib_coverage-summary PROPERTIES DEPENDS - zlib-coverage) - set(CMAKE_C_FLAGS - ${CFLAGS_OLD} - CACHE STRING "" FORCE) + if (GCOV_EXECUTABLE) + add_executable(infcover infcover.c) + target_link_libraries(infcover ZLIB::ZLIBSTATIC) + target_compile_options(infcover PRIVATE -coverage) + target_link_options(infcover PRIVATE -coverage) + target_compile_definitions( + infcover PRIVATE $<$:HAVE_HIDDEN>) + add_test(NAME zlib_coverage COMMAND infcover) + set(INFCOVER_DIR ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/infcover.dir) + add_test( + NAME zlib_coverage-summary + COMMAND + ${GCOV_EXECUTABLE} ${llvm_option} + ${CMAKE_CURRENT_SOURCE_DIR}/infcover.c -o + ${INFCOVER_DIR}/infcover.c.gcda) + set_tests_properties(zlib_coverage-summary PROPERTIES DEPENDS + zlib-coverage) + set(CMAKE_C_FLAGS + ${CFLAGS_OLD} + CACHE STRING "" FORCE) + endif(GCOV_EXECUTABLE) endif(${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID} STREQUAL "Clang") -- cgit v1.2.3-55-g6feb