Skip to content
Tcl Source Code Artifact [e167f104a5]
Login

Artifact [e167f104a5]

Artifact e167f104a5470bb1d8de56f8d19c05247b38b6db9ba8d7111ca25a454a1b37b4:


cmake_minimum_required(VERSION 3.15...3.31)

project(
    zlib_find_package_test
    LANGUAGES C
    VERSION @zlib_VERSION@)

option(ZLIB_BUILD_SHARED "" @ZLIB_BUILD_SHARED@)
option(ZLIB_BUILD_STATIC "" @ZLIB_BUILD_STATIC@)

if(ZLIB_BUILD_SHARED)
    find_package(ZLIB @zlib_VERSION@ CONFIG COMPONENTS shared REQUIRED)
    add_executable(test_example @zlib_SOURCE_DIR@/test/example.c)
    target_link_libraries(test_example ZLIB::ZLIB)

    if(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
        add_test(NAME zlib_test_example_shared COMMAND test_example)
    endif(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
endif(ZLIB_BUILD_SHARED)

if(ZLIB_BUILD_STATIC)
    find_package(ZLIB @zlib_VERSION@ CONFIG COMPONENTS static REQUIRED)
    add_executable(test_example_static @zlib_SOURCE_DIR@/test/example.c)
    target_link_libraries(test_example_static ZLIB::ZLIBSTATIC)
    add_test(NAME zlib_test_example_static COMMAND test_example_static)
endif(ZLIB_BUILD_STATIC)