From cb47dd85a9e4b4bf66c4de6da57ac04785573034 Mon Sep 17 00:00:00 2001 From: Vollstrecker Date: Wed, 11 Dec 2024 09:14:00 +0100 Subject: [PATCH] add minizip superseeds #835 --- CMakeLists.txt | 5 + contrib/minizip/CMakeLists.txt | 382 ++++++++++++++++++ contrib/minizip/minizip.pc.txt | 13 + contrib/minizip/minizipConfig.cmake.in | 5 + contrib/minizip/test/CMakeLists.txt | 139 +++++++ .../add_subdirectory_exclude_test.cmake.in | 25 ++ .../test/add_subdirectory_test.cmake.in | 25 ++ .../minizip/test/find_package_test.cmake.in | 24 ++ contrib/minizip/test/test_helper.cm | 32 ++ 9 files changed, 650 insertions(+) create mode 100644 contrib/minizip/CMakeLists.txt create mode 100644 contrib/minizip/minizip.pc.txt create mode 100644 contrib/minizip/minizipConfig.cmake.in create mode 100644 contrib/minizip/test/CMakeLists.txt create mode 100644 contrib/minizip/test/add_subdirectory_exclude_test.cmake.in create mode 100644 contrib/minizip/test/add_subdirectory_test.cmake.in create mode 100644 contrib/minizip/test/find_package_test.cmake.in create mode 100644 contrib/minizip/test/test_helper.cm diff --git a/CMakeLists.txt b/CMakeLists.txt index 583151c2f..b777ad7af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ project(zlib option(ZLIB_BUILD_TESTING "Enable Zlib Examples as tests" ON) option(ZLIB_BUILD_SHARED "Enable building zlib shared library" ON) option(ZLIB_BUILD_STATIC "Enable building zlib static library" ON) +option(ZLIB_BUILD_MINIZIP "Enable building libminizip contrib library" OFF) option(ZLIB_INSTALL_LIBRARIES "Enable installation of zlib" ON) option(ZLIB_PREFIX "prefix for all types and library functions, see zconf.h.in" @@ -337,3 +338,7 @@ if(ZLIB_BUILD_TESTING) add_subdirectory(test) endif(ZLIB_BUILD_TESTING) + +if(ZLIB_BUILD_MINIZIP) + add_subdirectory(contrib/minizip/) +endif(ZLIB_BUILD_MINIZIP) diff --git a/contrib/minizip/CMakeLists.txt b/contrib/minizip/CMakeLists.txt new file mode 100644 index 000000000..88ded2e9b --- /dev/null +++ b/contrib/minizip/CMakeLists.txt @@ -0,0 +1,382 @@ +cmake_minimum_required(VERSION 3.12) + +project(minizip + VERSION 1.0.0 + LANGUAGES C) + +option(MINIZIP_BUILD_SHARED "Enable building zlib shared library" ON) +option(MINIZIP_BUILD_STATIC "Enable building zlib static library" ON) +option(MINIZIP_BUILD_TESTING "Enable testing of minizip" ON) +option(MINIZIP_ENABLE_BZIP2 "Build minizip withj bzip2 support" ON) +option(MINIZIP_INSTALL "Enable installation of minizip" ON) + +if(MINGW) + option(MINIZIP_INSTALL_COMPAT_DLL "Install a copy as libminizip-1.dll" ON) +endif(MINGW) + +include(CheckFunctionExists) +include(CheckIncludeFile) +include(CheckCSourceCompiles) +include(CMakePackageConfigHelpers) +include(GNUInstallDirs) + +if(MINIZIP_ENABLE_BZIP2) + find_package(BZip2) +endif(MINIZIP_ENABLE_BZIP2) + +# +# Check for fopen64 +# +check_function_exists(fopen64 HAVE_FOPEN64) + +# +# Check for fseeko +# +check_function_exists(fseeko HAVE_FSEEKO) + +# +# Check for unistd.h +# +check_include_file(unistd.h HAVE_UNISTD_H) + +# +# Check to see if we have large file support +# +set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1) +check_type_size(off64_t OFF64_T) +unset(CMAKE_REQUIRED_DEFINITIONS) # clear variable + +# +# Check visibility attribute is supported +if(MSVC) + set(CMAKE_REQUIRED_FLAGS "-WX") +else(MSVC) + set(CMAKE_REQUIRED_FLAGS "-WError") +endif(MSVC) + +check_c_source_compiles( + " + #include + static void f(void) __attribute__ ((visibility(\"hidden\"))); + int main(void) {return 0;} + " + HAVE___ATTR__VIS_HIDDEN) + +unset(CMAKE_REQUIRED_FLAGS) + +if(NOT TARGET ZLIB::ZLIB) + find_package(zlib REQUIRED) +endif(NOT TARGET ZLIB::ZLIB) + +set(LIBMINIZIP_SRCS + ioapi.c + mztools.c + unzip.c + zip.c) + +set(LIBMINIZIP_HDRS + crypt.h + ioapi.h + mztools.h + unzip.h + zip.h) + +set(MINIZIP_SRCS + ioapi.c + $<$:iowin32.c> + minizip.c + zip.c) + +set(MINIZIP_HDRS + crypt.h + ints.h + ioapi.h + $<$:iowin32.h> + skipset.h + zip.h) + +set(MINIUNZIP_SRCS + ioapi.c + $<$:iowin32.c> + miniunz.c + unzip.c + zip.c) + +set(MINIUNZIP_HDRS + crypt.h + ints.h + ioapi.h + $<$:iowin32.h> + skipset.h + unzip.h + zip.h) + +if(WIN32) + set(minizip_static_suffix "s") + set(CMAKE_DEBUG_POSTFIX "d") +endif(WIN32) + +if(MINIZIP_BUILD_SHARED) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) + add_library(libminizip SHARED + ${LIBMINIZIP_SRCS} + ${LIBMINIZIP_HDRS}) + add_library(MINIZIP::MINIZIP ALIAS libminizip) + target_include_directories(libminizip PUBLIC + $ + $) + target_compile_definitions(libminizip + PRIVATE + $<$:_CRT_SECURE_NO_WARNINGS> + $<$:HAVE_BZIP2=1> + $<$:HAVE_HIDDEN> + $<$:HAVE_UNISTD_H=1> + $<$:USE_FILE32API=1> + PUBLIC + $<$:_LARGEFILE64_SOURCE=1>) + + if(NOT CYGWIN) + set_target_properties(libminizip PROPERTIES + SOVERSION ${minizip_VERSION_MAJOR}) + endif(NOT CYGWIN) + + set_target_properties(libminizip PROPERTIES + EXPORT_NAME MINIZIP + OUTPUT_NAME minizip + VERSIOM ${minizip_VERSION} + SOVERSION ${minizip_VERSION_MAJOR}) + target_link_libraries(libminizip + PUBLIC + $<$:BZip2::BZip2> + ZLIB::ZLIB) + + add_executable(minizip + ${MINIZIP_SRCS} + ${MINIZIP_HDRS}) + target_compile_definitions(minizip + PRIVATE + $<$:_CRT_SECURE_NO_WARNINGS> + $<$:USE_FILE32API=1>) + target_link_libraries(minizip PRIVATE MINIZIP::MINIZIP) + + add_executable(miniunzip + ${MINIUNZIP_SRCS} + ${MINIUNZIP_HDRS}) + target_compile_definitions(miniunzip + PRIVATE + $<$:_CRT_SECURE_NO_WARNINGS> + $<$:USE_FILE32API=1>) + target_link_libraries(miniunzip PRIVATE MINIZIP::MINIZIP) +endif(MINIZIP_BUILD_SHARED) + +if(MINIZIP_BUILD_STATIC) + + add_library(libminizipstatic STATIC + ${LIBMINIZIP_SRCS} + ${LIBMINIZIP_HDRS}) + add_library(MINIZIP::MINIZIPSTATIC ALIAS libminizipstatic) + target_include_directories(libminizipstatic PUBLIC + $ + $) + target_compile_definitions(libminizipstatic + PRIVATE + $<$:_CRT_SECURE_NO_WARNINGS> + $<$:HAVE_BZIP2=1> + $<$:HAVE_HIDDEN> + $<$:HAVE_UNISTD_H=1> + $<$:USE_FILE32API=1> + PUBLIC + $<$:_LARGEFILE64_SOURCE=1>) + set_target_properties(libminizipstatic PROPERTIES + EXPORT_NAME MINIZIPSTATIC + OUTPUT_NAME minizip${minizip_static_suffix}) + + if(CYGWIN) + set_target_properties(libminizipstatic PROPERTIES + SUFFIX ".dll.a") + endif(CYGWIN) + + target_link_libraries(libminizipstatic + PUBLIC + $<$:BZip2::BZip2> + ZLIB::ZLIBSTATIC) + + add_executable(minizipstatic + ${MINIZIP_SRCS} + ${MINIZIP_HDRS}) + target_compile_definitions(minizipstatic + PRIVATE + $<$:_CRT_SECURE_NO_WARNINGS> + $<$:USE_FILE32API=1>) + target_link_libraries(minizipstatic PRIVATE MINIZIP::MINIZIPSTATIC) + + add_executable(miniunzipstatic + ${MINIUNZIP_SRCS} + ${MINIUNZIP_HDRS}) + target_compile_definitions(miniunzipstatic + PRIVATE + $<$:_CRT_SECURE_NO_WARNINGS> + $<$:USE_FILE32API=1>) + target_link_libraries(miniunzipstatic PRIVATE MINIZIP::MINIZIPSTATIC) +endif(MINIZIP_BUILD_STATIC) + +if(MINIZIP_INSTALL) + if(MINIZIP_BUILD_SHARED) + install(TARGETS libminizip minizip miniunzip + COMPONENT Runtime + EXPORT minizipExport + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") + if(MINIZIP_INSTALL_COMPAT_DLL) + install(FILES $ + COMPONENT Runtime + RENAME libminizip-${minizip_VERSION_MAJOR}.dll + DESTINATION "${CMAKE_INSTALL_BINDIR}") + endif(MINIZIP_INSTALL_COMPAT_DLL) + + if(MSVC) + install(FILES $ + COMPONENT Runtime + DESTINATION ${CMAKE_INSTALL_BINDIR} + CONFIGURATIONS Debug OR RelWithDebInfo + OPTIONAL + ) + endif(MSVC) + endif(MINIZIP_BUILD_SHARED) + + if(MINIZIP_BUILD_STATIC) + install(TARGETS libminizipstatic + COMPONENT Development + TARGETS minizipstatic miniunzipstatic + COMPONENT Runtime + EXPORT minizipExport + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") + endif(MINIZIP_BUILD_STATIC) + + configure_package_config_file(${minizip_SOURCE_DIR}/minizipConfig.cmake.in + ${minizip_BINARY_DIR}/minizipConfig.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/minizip + NO_CHECK_REQUIRED_COMPONENTS_MACRO) + + write_basic_package_version_file( + "${minizip_BINARY_DIR}/minizipConfigVersion.cmake" + VERSION "${minizip_VERSION}" + COMPATIBILITY AnyNewerVersion) + + install(FILES + ${minizip_BINARY_DIR}/minizipConfig.cmake + ${minizip_BINARY_DIR}/minizipConfigVersion.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/minizip) + + install(EXPORT minizipExport + FILE minizip.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/minizip + NAMESPACE MINIZIP::) + + install(FILES ${LIBMINIZIP_HDRS} + COMPONENT Development + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") +endif(MINIZIP_INSTALL) + +if(MINIZIP_BUILD_TESTING) + enable_testing() + + if(MINIZIP_BUILD_SHARED AND NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll") + add_test(NAME minizip_prepare_shared_zip + COMMAND ${CMAKE_COMMAND} -DCREATE_SHARED=ON + -P ${CMAKE_CURRENT_SOURCE_DIR}/test/test_helper.cm + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test) + add_test(NAME minizip_zipping_test_file_shared + COMMAND minizip test_file_shared.zip test_file_shared.txt + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test) + add_test(NAME minizip_prepare_shared_unzip + COMMAND ${CMAKE_COMMAND} -DMOVE_SHARED=ON + -P ${CMAKE_CURRENT_SOURCE_DIR}/test/test_helper.cm + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test) + add_test(NAME minizip_miniunzipping_test_file_shared.zip + COMMAND miniunzip test_file_shared.zip + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test) + add_test(NAME minizip_compare_shared + COMMAND ${CMAKE_COMMAND} -E compare_files + test_file_shared.txt test_file_shared.orig + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test) + add_test(NAME minizip_clean_shared_zip + COMMAND ${CMAKE_COMMAND} -DDELETE_SHARED=ON + -P ${CMAKE_CURRENT_SOURCE_DIR}/test/test_helper.cm + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test) + set_tests_properties(minizip_prepare_shared_zip + PROPERTIES + FIXTURES_SETUP prepare_shared) + set_tests_properties(minizip_zipping_test_file_shared + PROPERTIES + FIXTURES_REQUIRED prepare_shared + FIXTURES_SETUP zip_shared) + set_tests_properties(minizip_prepare_shared_unzip + PROPERTIES + FIXTURES_REQUIRED zip_shared + FIXTURES_SETUP prepare_unzip_shared) + set_tests_properties(minizip_miniunzipping_test_file_shared.zip + PROPERTIES + FIXTURES_REQUIRED prepare_unzip_shared + FIXTURES_SETUP prepare_compare_shared) + set_tests_properties(minizip_compare_shared + PROPERTIES + FIXTURES_REQUIRED prepare_compare_shared + FIXTURES_SETUP compared_shared) + set_tests_properties(minizip_clean_shared_zip + PROPERTIES + FIXTURES_CLEANUP compared_shared) + endif(MINIZIP_BUILD_SHARED AND NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll") + + if(MINIZIP_BUILD_STATIC) + add_test(NAME minizip_prepare_static_zip + COMMAND ${CMAKE_COMMAND} -DCREATE_STATIC=ON + -P ${CMAKE_CURRENT_SOURCE_DIR}/test/test_helper.cm + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test) + add_test(NAME minizip_zipping_test_file_static + COMMAND minizipstatic test_file_static.zip test_file_static.txt + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test) + add_test(NAME minizip_prepare_static_unzip + COMMAND ${CMAKE_COMMAND} -DMOVE_STATIC=ON + -P ${CMAKE_CURRENT_SOURCE_DIR}/test/test_helper.cm + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test) + add_test(NAME minizip_miniunzipping_test_file_static.zip + COMMAND miniunzipstatic test_file_static.zip + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test) + add_test(NAME minizip_compare_static + COMMAND ${CMAKE_COMMAND} -E compare_files + test_file_static.txt test_file_static.orig + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test) + add_test(NAME minizip_clean_static_zip + COMMAND ${CMAKE_COMMAND} -DDELETE_STATIC=ON + -P ${CMAKE_CURRENT_SOURCE_DIR}/test/test_helper.cm + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test) + set_tests_properties(minizip_prepare_static_zip + PROPERTIES + FIXTURES_SETUP prepare_static) + set_tests_properties(minizip_zipping_test_file_static + PROPERTIES + FIXTURES_REQUIRED prepare_static + FIXTURES_SETUP zip_static) + set_tests_properties(minizip_prepare_static_unzip + PROPERTIES + FIXTURES_REQUIRED zip_static + FIXTURES_SETUP prepare_unzip_static) + set_tests_properties(minizip_miniunzipping_test_file_static.zip + PROPERTIES + FIXTURES_REQUIRED prepare_unzip_static + FIXTURES_SETUP prepare_compare_static) + set_tests_properties(minizip_compare_static + PROPERTIES + FIXTURES_REQUIRED prepare_compare_static + FIXTURES_SETUP compared_static) + set_tests_properties(minizip_clean_static_zip + PROPERTIES + FIXTURES_CLEANUP compared_static) + endif(MINIZIP_BUILD_STATIC) + + add_subdirectory(test) +endif(MINIZIP_BUILD_TESTING) diff --git a/contrib/minizip/minizip.pc.txt b/contrib/minizip/minizip.pc.txt new file mode 100644 index 000000000..060ab091c --- /dev/null +++ b/contrib/minizip/minizip.pc.txt @@ -0,0 +1,13 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ +sharedlibdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ +includedir=${exec_prefix}/@CMAKE_INSTALL_INCLUDEDIR@ + +Name: minizip +Description: minizip compression library +Version: @minizip_VERSION@ + +Requires: +Libs: -L${libdir} -L${sharedlibdir} -lz -lminizip +Cflags: -I${includedir} diff --git a/contrib/minizip/minizipConfig.cmake.in b/contrib/minizip/minizipConfig.cmake.in new file mode 100644 index 000000000..5221bfeaa --- /dev/null +++ b/contrib/minizip/minizipConfig.cmake.in @@ -0,0 +1,5 @@ +set(minizip_VERSION @minizip_VERSION@) +set(MINIZIP_ENABLE_BZIP2 @MINIZIP_ENABLE_BZIP2@ +@PACKAGE_INIT@ +INCLUDE (${CMAKE_CURRENT_LIST_DIR}/minizip.cmake) +find_dependency(zlib) diff --git a/contrib/minizip/test/CMakeLists.txt b/contrib/minizip/test/CMakeLists.txt new file mode 100644 index 000000000..345718c31 --- /dev/null +++ b/contrib/minizip/test/CMakeLists.txt @@ -0,0 +1,139 @@ +add_test(NAME minizip_test_install + COMMAND ${CMAKE_COMMAND} --install ${zlib_BINARY_DIR} + --prefix ${CMAKE_CURRENT_BINARY_DIR}/test_install + --config $ + WORKING_DIRECTORY ${zlib_BINARY_DIR}) + +set_tests_properties(minizip_test_install + PROPERTIES + FIXTURES_SETUP minizip_install) + +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectoy_test) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/find_package_test.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test/CMakeLists.txt) + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_test.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectoy_test/CMakeLists.txt) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_exclude_test.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test/CMakeLists.txt) + +# CMAKE_GENERATOR_PLATFORM doesn't work in the if +set(GENERATOR ${CMAKE_GENERATOR_PLATFORM}) + +if(GENERATOR) + set(PLATFORM "-A ${GENERATOR}") +endif(GENERATOR) + +# +# findpackage_test +# +add_test(NAME minizip_configure_find_package + COMMAND ${CMAKE_COMMAND} + ${PLATFORM} + -B${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build + -DCMAKE_BUILD_TYPE=$ + -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} + -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_install + -DZDIR=${CMAKE_CURRENT_BINARY_DIR}/test_install/${CMAKE_INSTALL_LIBDIR} + --fresh + -G "${CMAKE_GENERATOR}" + -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test) + +add_test(NAME minizip_build_find_package + COMMAND ${CMAKE_COMMAND} --build . + --config $ + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build) + +add_test(NAME minizip_test_find_package + COMMAND ${CMAKE_CTEST_COMMAND} -C $ + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build) + +set_tests_properties(minizip_configure_find_package PROPERTIES + FIXTURES_REQUIRED minizip_install + FIXTURES_SETUP mzfp_config) + +set_tests_properties(minizip_build_find_package PROPERTIES + FIXTURES_REQUIRED mzfp_config + FIXTURES_SETUP mzfp_build) + +set_tests_properties(minizip_test_find_package PROPERTIES + FIXTURES_REQUIRED mzfp_build + ENVIRONMENT CTEST_OUTPUT_ON_FAILURE=1) + +# +# add_subdirectory_test +# +add_test(NAME minizip_configure_add_subdirectory + COMMAND ${CMAKE_COMMAND} + ${PLATFORM} + -B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build + -DCMAKE_BUILD_TYPE=$ + -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} + -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_install + --fresh + -G "${CMAKE_GENERATOR}" + -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test) + +add_test(NAME minizip_build_add_subdirectory + COMMAND ${CMAKE_COMMAND} --build . + --config $ + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build) + +add_test(NAME minizip_test_add_subdirectory + COMMAND ${CMAKE_CTEST_COMMAND} -C $ + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build) + +set_tests_properties(minizip_configure_add_subdirectory PROPERTIES + FIXTURES_REQUIRED minizip_install + FIXTURES_SETUP mzas_config) + +set_tests_properties(minizip_build_add_subdirectory PROPERTIES + FIXTURES_REQUIRED mzas_config + FIXTURES_SETUP mzas_build) + +set_tests_properties(minizip_test_add_subdirectory PROPERTIES + FIXTURES_REQUIRED mzas_build + ENVIRONMENT CTEST_OUTPUT_ON_FAILURE=1) + +# +# add_subdirectory_exclude_test +# +add_test(NAME minizip_configure_add_subdirectory_exclude + COMMAND ${CMAKE_COMMAND} + ${PLATFORM} + -B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build + -DCMAKE_BUILD_TYPE=$ + -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} + -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_install + --fresh + -G "${CMAKE_GENERATOR}" + -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test) + +add_test(NAME minizip_build_add_subdirectory_exclude + COMMAND ${CMAKE_COMMAND} --build . + --config $ + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build) + +add_test(NAME minizip_test_add_subdirectory_exclude + COMMAND ${CMAKE_CTEST_COMMAND} -C $ + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build) + +set_tests_properties(minizip_configure_add_subdirectory_exclude PROPERTIES + FIXTURES_REQUIRED minizip_install + FIXTURES_SETUP mzasx_config) + +set_tests_properties(minizip_build_add_subdirectory_exclude PROPERTIES + FIXTURES_REQUIRED mzasx_config + FIXTURES_SETUP mzasx_build) + +set_tests_properties(minizip_test_add_subdirectory_exclude PROPERTIES + FIXTURES_REQUIRED mzasx_build + ENVIRONMENT CTEST_OUTPUT_ON_FAILURE=1) diff --git a/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in b/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in new file mode 100644 index 000000000..9dd9d35e7 --- /dev/null +++ b/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 3.5) + +project(zlib_find_package_test + LANGUAGES C + VERSION ${zlib_VERSION}) + +enable_testing() +set(ZLIB_BUILD_TESTING OFF) +add_subdirectory(${zlib_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/zlib EXCLUDE_FROM_ALL) + +if(${ZLIB_BUILD_SHARED}) + 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}) + 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}) diff --git a/contrib/minizip/test/add_subdirectory_test.cmake.in b/contrib/minizip/test/add_subdirectory_test.cmake.in new file mode 100644 index 000000000..c10f7095c --- /dev/null +++ b/contrib/minizip/test/add_subdirectory_test.cmake.in @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 3.5) + +project(zlib_find_package_test + LANGUAGES C + VERSION ${zlib_VERSION}) + +enable_testing() +set(ZLIB_BUILD_TESTING OFF) +add_subdirectory(${zlib_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/zlib) + +if(${ZLIB_BUILD_SHARED}) + 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}) + 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}) diff --git a/contrib/minizip/test/find_package_test.cmake.in b/contrib/minizip/test/find_package_test.cmake.in new file mode 100644 index 000000000..42f3c19e7 --- /dev/null +++ b/contrib/minizip/test/find_package_test.cmake.in @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.5) + +project(zlib_find_package_test + LANGUAGES C + VERSION ${zlib_VERSION}) + +enable_testing() +find_package(zlib ${zlib_VERSION} CONFIG REQUIRED) + +if(${ZLIB_BUILD_SHARED}) + 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}) + 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}) diff --git a/contrib/minizip/test/test_helper.cm b/contrib/minizip/test/test_helper.cm new file mode 100644 index 000000000..99ae45e2f --- /dev/null +++ b/contrib/minizip/test/test_helper.cm @@ -0,0 +1,32 @@ +if(CREATE_SHARED) + file(REMOVE ./test_file_shared.orig ./test_file_shared.zip) + file(WRITE ./test_file_shared.txt "Hello Hello Hello") +endif(CREATE_SHARED) + +if(MOVE_SHARED) + file(RENAME ./test_file_shared.txt ./test_file_shared.orig) +endif(MOVE_SHARED) + +if(DELETE_SHARED) + file(REMOVE + ./test_file_shared.txt + ./test_file_shared.orig + ./test_file_shared.zip) +endif(DELETE_SHARED) + +if(CREATE_STATIC) + file(REMOVE ./test_file_static.orig ./test_file_static.zip) + file(WRITE ./test_file_static.txt "Hello Hello Hello") +endif(CREATE_STATIC) + +if(MOVE_STATIC) + file(RENAME ./test_file_static.txt ./test_file_static.orig) +endif(MOVE_STATIC) + +if(DELETE_STATIC) + file(REMOVE + ./test_file_static.txt + ./test_file_static.orig + ./test_file_static.zip) +endif(DELETE_STATIC) +