From 155d88378e76b3bf123da4301a5b82aad17d06bc Mon Sep 17 00:00:00 2001 From: Vollstrecker Date: Thu, 5 Dec 2024 17:22:17 +0100 Subject: [PATCH] CMake: Test static builds. --- CMakeLists.txt | 57 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c5ca7136..e05b92b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -231,23 +231,46 @@ endif(ZLIB_INSTALL_LIBRARIES) #============================================================================ if(ZLIB_BUILD_TESTING) enable_testing() - add_executable(zlib_example test/example.c) - target_link_libraries(zlib_example ZLIB::ZLIB) - add_test(zlib_example zlib_example) - - add_executable(minigzip test/minigzip.c) - target_link_libraries(minigzip ZLIB::ZLIB) - - if(HAVE_OFF64_T) - add_executable(zlib_example64 test/example.c) - target_compile_definitions(zlib_example64 PRIVATE LARGEFILE64_SOURCE=1) - target_link_libraries(zlib_example64 ZLIB::ZLIB) - add_test(zlib_example64 zlib_example64) - - add_executable(minigzip64 test/minigzip.c) - target_compile_definitions(minigzip64 PRIVATE LARGEFILE64_SOURCE=1) - target_link_libraries(minigzip64 ZLIB::ZLIB) - endif(HAVE_OFF64_T) + + if(ZLIB_BUILD_SHARED) + add_executable(zlib_example test/example.c) + target_link_libraries(zlib_example ZLIB::ZLIB) + add_test(zlib_example zlib_example) + + add_executable(minigzip test/minigzip.c) + target_link_libraries(minigzip ZLIB::ZLIB) + + if(HAVE_OFF64_T) + add_executable(zlib_example64 test/example.c) + target_compile_definitions(zlib_example64 PRIVATE LARGEFILE64_SOURCE=1) + target_link_libraries(zlib_example64 ZLIB::ZLIB) + add_test(zlib_example64 zlib_example64) + + add_executable(minigzip64 test/minigzip.c) + target_compile_definitions(minigzip64 PRIVATE LARGEFILE64_SOURCE=1) + target_link_libraries(minigzip64 ZLIB::ZLIB) + endif(HAVE_OFF64_T) + endif(ZLIB_BUILD_SHARED) + + if(ZLIB_BUILD_STATIC) + add_executable(zlib_static_example test/example.c) + target_link_libraries(zlib_static_example ZLIB::ZLIBSTATIC) + add_test(zlib_static_example zlib_static_example) + + add_executable(static_minigzip test/minigzip.c) + target_link_libraries(static_minigzip ZLIB::ZLIBSTATIC) + + if(HAVE_OFF64_T) + add_executable(zlib_static_example64 test/example.c) + target_compile_definitions(zlib_static_example64 PRIVATE LARGEFILE64_SOURCE=1) + target_link_libraries(zlib_static_example64 ZLIB::ZLIBSTATIC) + add_test(zlib_static_example64 zlib_static_example64) + + add_executable(static_minigzip64 test/minigzip.c) + target_compile_definitions(static_minigzip64 PRIVATE LARGEFILE64_SOURCE=1) + target_link_libraries(static_minigzip64 ZLIB::ZLIBSTATIC) + endif(HAVE_OFF64_T) + endif(ZLIB_BUILD_STATIC) add_subdirectory(test) endif(ZLIB_BUILD_TESTING)