if (ZLIB_ENABLE_TESTS)
enable_testing()
macro(configure_test_executable target)
- target_link_libraries(${target} zlib)
target_include_directories(${target} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
if(NOT WITH_GZFILEOP)
target_compile_definitions(${target} PUBLIC -DWITH_GZFILEOP)
add_executable(example test/example.c)
configure_test_executable(example)
+ target_link_libraries(example zlib)
+
set(EXAMPLE_COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:example>)
add_test(NAME example COMMAND ${EXAMPLE_COMMAND})
add_executable(minigzip test/minigzip.c)
configure_test_executable(minigzip)
+ if(NOT DEFINED BUILD_SHARED_LIBS)
+ target_link_libraries(minigzip zlibstatic)
+ else()
+ target_link_libraries(minigzip zlib)
+ endif()
add_executable(switchlevels test/switchlevels.c)
configure_test_executable(switchlevels)
+ target_link_libraries(switchlevels zlib)
add_executable(infcover test/infcover.c inftrees.c)
configure_test_executable(infcover)
+ target_link_libraries(infcover zlib)
add_executable(makefixed tools/makefixed.c inftrees.c)
target_include_directories(makefixed PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
if(HAVE_OFF64_T)
add_executable(example64 test/example.c)
configure_test_executable(example64)
+ target_link_libraries(example64 zlib)
set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
set(EXAMPLE64_COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:example64>)
add_test(NAME example64 COMMAND ${EXAMPLE64_COMMAND})
add_executable(minigzip64 test/minigzip.c)
configure_test_executable(minigzip64)
+ if(NOT DEFINED BUILD_SHARED_LIBS)
+ target_link_libraries(minigzip64 zlibstatic)
+ else()
+ target_link_libraries(minigzip64 zlib)
+ endif()
set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
endif()
foreach(FUZZER ${FUZZERS})
add_executable(${FUZZER}_fuzzer test/fuzz/${FUZZER}_fuzzer.c test/fuzz/standalone_fuzz_target_runner.c)
configure_test_executable(${FUZZER}_fuzzer)
+ target_link_libraries(${FUZZER}_fuzzer zlib)
set(FUZZER_COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:${FUZZER}_fuzzer> ${ALL_SRC_FILES})
add_test(NAME ${FUZZER}_fuzzer COMMAND ${FUZZER_COMMAND})
endforeach()