From 71045aef60fc8d808ce31993224eb49156c4698a Mon Sep 17 00:00:00 2001
From: Mark Adler <madler@alumni.caltech.edu>
Date: Mon, 30 Dec 2024 18:52:33 -0800
Subject: [PATCH 001/128] Fix indent in infback.c.

---
 infback.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/infback.c b/infback.c
index fd02e7090..6c7a034a7 100644
--- a/infback.c
+++ b/infback.c
@@ -46,7 +46,7 @@ int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits,
 #ifdef Z_SOLO
         return Z_STREAM_ERROR;
 #else
-    strm->zfree = zcfree;
+        strm->zfree = zcfree;
 #endif
     state = (struct inflate_state FAR *)ZALLOC(strm, 1,
                                                sizeof(struct inflate_state));

From 2359cd3d601a15ddafe7137a49651069c95a13c3 Mon Sep 17 00:00:00 2001
From: Josh Varga <josh.varga@gmail.com>
Date: Mon, 20 Jan 2025 00:02:41 -0600
Subject: [PATCH 002/128] Add Bazel targets.

---
 .gitignore   |  12 +++++
 BUILD.bazel  | 134 +++++++++++++++++++++++++++++++++++++++++++++++++++
 MODULE.bazel |   9 ++++
 3 files changed, 155 insertions(+)
 create mode 100644 BUILD.bazel
 create mode 100644 MODULE.bazel

diff --git a/.gitignore b/.gitignore
index e86742897..a06fb1095 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,3 +35,15 @@ contrib/vstudio/vc143/arm64
 contrib/nuget/bin
 contrib/nuget/obj
 *.included
+
+# Bazel directories
+/bazel-*
+/bazel-bin
+/bazel-genfiles
+/bazel-out
+/bazel-testlogs
+user.bazelrc
+
+# MODULE.bazel.lock is ignored for now as per this recommendation:
+# https://github.com/bazelbuild/bazel/issues/20369
+MODULE.bazel.lock
diff --git a/BUILD.bazel b/BUILD.bazel
new file mode 100644
index 000000000..9a294f2f2
--- /dev/null
+++ b/BUILD.bazel
@@ -0,0 +1,134 @@
+# Copied from https://github.com/bazelbuild/bazel-central-registry/tree/main/modules/zlib/1.3.1.bcr.4/patches
+# Adapted from https://github.com/protocolbuffers/protobuf/blob/master/third_party/zlib.BUILD
+
+#  Copyright 2008 Google Inc.  All rights reserved.
+#
+#  Redistribution and use in source and binary forms, with or without
+#  modification, are permitted provided that the following conditions are
+#  met:
+#
+#      * Redistributions of source code must retain the above copyright
+#  notice, this list of conditions and the following disclaimer.
+#      * Redistributions in binary form must reproduce the above
+#  copyright notice, this list of conditions and the following disclaimer
+#  in the documentation and/or other materials provided with the
+#  distribution.
+#      * Neither the name of Google Inc. nor the names of its
+#  contributors may be used to endorse or promote products derived from
+#  this software without specific prior written permission.
+#
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#  Code generated by the Protocol Buffer compiler is owned by the owner
+#  of the input file used when generating it.  This code is not
+#  standalone and requires a support library to be linked with it.  This
+#  support library is itself covered by the above license.
+
+load("@rules_cc//cc:defs.bzl", "cc_library")
+load("@rules_license//rules:license.bzl", "license")
+
+package(
+    default_applicable_licenses = [":license"],
+)
+
+license(
+    name = "license",
+    license_kinds = ["@rules_license//licenses/spdx:Zlib"],
+    license_text = "LICENSE",
+)
+
+exports_files([
+    "LICENSE",
+])
+
+_ZLIB_HEADERS = [
+    "crc32.h",
+    "deflate.h",
+    "gzguts.h",
+    "inffast.h",
+    "inffixed.h",
+    "inflate.h",
+    "inftrees.h",
+    "trees.h",
+    "zconf.h",
+    "zlib.h",
+    "zutil.h",
+]
+
+_ZLIB_PREFIXED_HEADERS = ["zlib/include/" + hdr for hdr in _ZLIB_HEADERS]
+
+# In order to limit the damage from the `includes` propagation
+# via `:zlib`, copy the public headers to a subdirectory and
+# expose those.
+genrule(
+    name = "copy_public_headers",
+    srcs = _ZLIB_HEADERS,
+    outs = _ZLIB_PREFIXED_HEADERS,
+    cmd_bash = "cp $(SRCS) $(@D)/zlib/include/",
+    cmd_bat = " && ".join(
+        ["@copy /Y \"$(location %s)\" \"$(@D)\\zlib\\include\\\"  >NUL" %
+         s for s in _ZLIB_HEADERS],
+    ),
+)
+
+config_setting(
+    name = "mingw_gcc_compiler",
+    flag_values = {
+        "@bazel_tools//tools/cpp:compiler": "mingw-gcc",
+    },
+    visibility = [":__subpackages__"],
+)
+
+cc_library(
+    name = "z",
+    srcs = [
+        "adler32.c",
+        "compress.c",
+        "crc32.c",
+        "deflate.c",
+        "gzclose.c",
+        "gzlib.c",
+        "gzread.c",
+        "gzwrite.c",
+        "infback.c",
+        "inffast.c",
+        "inflate.c",
+        "inftrees.c",
+        "trees.c",
+        "uncompr.c",
+        "zutil.c",
+        # Include the un-prefixed headers in srcs to work
+        # around the fact that zlib isn't consistent in its
+        # choice of <> or "" delimiter when including itself.
+    ] + _ZLIB_HEADERS,
+    hdrs = _ZLIB_PREFIXED_HEADERS,
+    copts = select({
+        ":mingw_gcc_compiler": [
+            "-fpermissive",
+        ],
+        "@platforms//os:windows": [],
+        "//conditions:default": [
+            "-Wno-deprecated-non-prototype",
+            "-Wno-unused-variable",
+            "-Wno-implicit-function-declaration",
+        ],
+    }),
+    includes = ["zlib/include/"],
+    visibility = ["//visibility:public"],
+)
+
+alias(
+    name = "zlib",
+    actual = ":z",
+    visibility = ["//visibility:public"],
+)
diff --git a/MODULE.bazel b/MODULE.bazel
new file mode 100644
index 000000000..cb4c13ef3
--- /dev/null
+++ b/MODULE.bazel
@@ -0,0 +1,9 @@
+module(
+    name = "zlib",
+    version = "0.0.0",
+    compatibility_level = 1,
+)
+
+bazel_dep(name = "platforms", version = "0.0.10")
+bazel_dep(name = "rules_cc", version = "0.0.16")
+bazel_dep(name = "rules_license", version = "1.0.0")

From b3907c2cd99908259c71fab6754f88e25d370fed Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Sat, 30 Nov 2024 16:19:11 +0100
Subject: [PATCH 003/128] CMake: Add options for shared and static build.

---
 CMakeLists.txt | 63 ++++++++++++++++++++++++++++++++++----------------
 1 file changed, 43 insertions(+), 20 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3d9b58df8..648f2c034 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,6 +6,8 @@ project(zlib C)
 set(VERSION "1.3.1.1")
 
 option(ZLIB_BUILD_EXAMPLES "Enable Zlib Examples" ON)
+option(ZLIB_BUILD_SHARED "Enable building zlib shared library" ON)
+option(ZLIB_BUILD_STATIC "Enable building zlib static library" ON)
 
 set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
 set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
@@ -150,18 +152,23 @@ if(MINGW)
     set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
 endif(MINGW)
 
-add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
-target_include_directories(zlib PUBLIC
-    $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
-    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
-add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
-target_include_directories(zlibstatic PUBLIC
-    $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
-    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
-set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
-set_target_properties(zlib PROPERTIES SOVERSION 1)
-
-if(NOT CYGWIN)
+if(ZLIB_BUILD_SHARED)
+    add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
+    target_include_directories(zlib PUBLIC
+        $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
+        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
+    set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
+    set_target_properties(zlib PROPERTIES SOVERSION 1)
+endif(ZLIB_BUILD_SHARED)
+
+if(ZLIB_BUILD_STATIC)
+    add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
+    target_include_directories(zlibstatic PUBLIC
+        $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
+        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
+endif(ZLIB_BUILD_STATIC)
+
+if(NOT CYGWIN AND ZLIB_BUILD_SHARED)
     # This property causes shared libraries on Linux to have the full version
     # encoded into their final filename.  We disable this on Cygwin because
     # it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll
@@ -174,20 +181,36 @@ endif()
 
 if(UNIX)
     # On unix-like platforms the library is almost always called libz
-   set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
-   if(NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
-     set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
-   endif()
+    if(ZLIB_BUILD_SHARED)
+        set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
+        if(NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
+            set_target_properties(zlib PROPERTIES
+                LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
+        endif()
+    endif(ZLIB_BUILD_SHARED)
+
+    if(ZLIB_BUILD_STATIC)
+        set_target_properties(zlibstatic PROPERTIES OUTPUT_NAME z)
+    endif(ZLIB_BUILD_STATIC)
 elseif(BUILD_SHARED_LIBS AND WIN32)
     # Creates zlib1.dll when building shared library version
     set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
 endif()
 
 if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
-    install(TARGETS zlib zlibstatic
-        RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
-        ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
-        LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
+    if(ZLIB_BUILD_SHARED)
+        install(TARGETS zlib
+            RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
+            ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
+            LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
+    endif(ZLIB_BUILD_SHARED)
+
+    if(ZLIB_BUILD_STATIC)
+        install(TARGETS zlibstatic
+            RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
+            ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
+            LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
+    endif(ZLIB_BUILD_STATIC)
 endif()
 if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
     install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${INSTALL_INC_DIR}")

From ee00230f8e8e75e4175cc8f30c9686245a686d5c Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Sat, 30 Nov 2024 18:32:05 +0100
Subject: [PATCH 004/128] CMake: Switch to GNUInstallDirs.

---
 CMakeLists.txt | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 648f2c034..b9029403c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,16 +9,11 @@ option(ZLIB_BUILD_EXAMPLES "Enable Zlib Examples" ON)
 option(ZLIB_BUILD_SHARED "Enable building zlib shared library" ON)
 option(ZLIB_BUILD_STATIC "Enable building zlib static library" ON)
 
-set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
-set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
-set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers")
-set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages")
-set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
-
 include(CheckTypeSize)
 include(CheckFunctionExists)
 include(CheckIncludeFile)
 include(CheckCSourceCompiles)
+include(GNUInstallDirs)
 enable_testing()
 
 check_include_file(sys/types.h HAVE_SYS_TYPES_H)
@@ -200,26 +195,26 @@ endif()
 if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
     if(ZLIB_BUILD_SHARED)
         install(TARGETS zlib
-            RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
-            ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
-            LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
+            RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+            ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+            LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" )
     endif(ZLIB_BUILD_SHARED)
 
     if(ZLIB_BUILD_STATIC)
         install(TARGETS zlibstatic
-            RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
-            ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
-            LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
+            RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+            ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+            LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" )
     endif(ZLIB_BUILD_STATIC)
 endif()
 if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
-    install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${INSTALL_INC_DIR}")
+    install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
 endif()
 if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
-    install(FILES zlib.3 DESTINATION "${INSTALL_MAN_DIR}/man3")
+    install(FILES zlib.3 DESTINATION "${CMAKE_INSTALL_MANDIR}/man3")
 endif()
 if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
-    install(FILES ${ZLIB_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}")
+    install(FILES ${ZLIB_PC} DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
 endif()
 
 #============================================================================

From 74247f0947e4156551f0ba66ef0993c8147750a5 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Sat, 30 Nov 2024 23:34:02 +0100
Subject: [PATCH 005/128] CMake: Install libs with static and debug suffix.

Add option to also install zlib1.ddl for compatibility.
---
 CMakeLists.txt | 37 ++++++++++++++++++++++++-------------
 1 file changed, 24 insertions(+), 13 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b9029403c..fc234f103 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,6 +9,10 @@ option(ZLIB_BUILD_EXAMPLES "Enable Zlib Examples" ON)
 option(ZLIB_BUILD_SHARED "Enable building zlib shared library" ON)
 option(ZLIB_BUILD_STATIC "Enable building zlib static library" ON)
 
+if(WIN32)
+    option(ZLIB_INSTALL_COMPAT_DLL "Install a copy as zlib1.dll" ON)
+endif(WIN32)
+
 include(CheckTypeSize)
 include(CheckFunctionExists)
 include(CheckIncludeFile)
@@ -56,7 +60,6 @@ endif()
 check_include_file(unistd.h Z_HAVE_UNISTD_H)
 
 if(MSVC)
-    set(CMAKE_DEBUG_POSTFIX "d")
     add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
     add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
     include_directories(${CMAKE_CURRENT_SOURCE_DIR})
@@ -147,13 +150,21 @@ if(MINGW)
     set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
 endif(MINGW)
 
+if(WIN32)
+    set (zlib_static_suffix "s")
+    set (zlib_debug_suffix "d")
+endif(WIN32)
+
 if(ZLIB_BUILD_SHARED)
     add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
     target_include_directories(zlib PUBLIC
         $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
         $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
-    set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
-    set_target_properties(zlib PROPERTIES SOVERSION 1)
+    set_target_properties(zlib PROPERTIES
+        DEFINE_SYMBOL ZLIB_DLL
+        SOVERSION 1
+        PROPERTIES OUTPUT_NAME z
+        PROPERTIES OUTPUT_NAME_DEBUG z${zlib_debug_suffix})
 endif(ZLIB_BUILD_SHARED)
 
 if(ZLIB_BUILD_STATIC)
@@ -161,6 +172,9 @@ if(ZLIB_BUILD_STATIC)
     target_include_directories(zlibstatic PUBLIC
         $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
         $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
+    set_target_properties(zlibstatic PROPERTIES
+        PROPERTIES OUTPUT_NAME z${zlib_static_suffix}
+        PROPERTIES OUTPUT_NAME_DEBUG z${zlib_static_suffix}${zlib_debug_suffix})
 endif(ZLIB_BUILD_STATIC)
 
 if(NOT CYGWIN AND ZLIB_BUILD_SHARED)
@@ -177,19 +191,11 @@ endif()
 if(UNIX)
     # On unix-like platforms the library is almost always called libz
     if(ZLIB_BUILD_SHARED)
-        set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
         if(NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
             set_target_properties(zlib PROPERTIES
                 LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
         endif()
     endif(ZLIB_BUILD_SHARED)
-
-    if(ZLIB_BUILD_STATIC)
-        set_target_properties(zlibstatic PROPERTIES OUTPUT_NAME z)
-    endif(ZLIB_BUILD_STATIC)
-elseif(BUILD_SHARED_LIBS AND WIN32)
-    # Creates zlib1.dll when building shared library version
-    set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
 endif()
 
 if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
@@ -197,14 +203,19 @@ if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
         install(TARGETS zlib
             RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
             ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
-            LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" )
+            LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
+        if(ZLIB_INSTALL_COMPAT_DLL)
+            install(FILES  $<TARGET_FILE:zlib>
+                RENAME zlib1.dll
+                DESTINATION "${CMAKE_INSTALL_BINDIR}")
+        endif(ZLIB_INSTALL_COMPAT_DLL)
     endif(ZLIB_BUILD_SHARED)
 
     if(ZLIB_BUILD_STATIC)
         install(TARGETS zlibstatic
             RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
             ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
-            LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" )
+            LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
     endif(ZLIB_BUILD_STATIC)
 endif()
 if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )

From ae5946e5d8accf8b0b101e7b77477a958d0b7185 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Sat, 30 Nov 2024 23:42:03 +0100
Subject: [PATCH 006/128] CMake: Add pdb install.

Adjust minimum required version for regex.
---
 CMakeLists.txt | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index fc234f103..ce5ce3547 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 2.4.4...3.15.0)
+cmake_minimum_required(VERSION 3.1)
 set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
 
 project(zlib C)
@@ -209,6 +209,15 @@ if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
                 RENAME zlib1.dll
                 DESTINATION "${CMAKE_INSTALL_BINDIR}")
         endif(ZLIB_INSTALL_COMPAT_DLL)
+
+        if(MSVC)
+            install(FILES $<TARGET_PDB_FILE:zlib>
+                DESTINATION ${CMAKE_INSTALL_BINDIR}
+                CONFIGURATIONS Debug OR RelWithDebInfo
+                OPTIONAL
+            )
+        endif(MSVC)
+
     endif(ZLIB_BUILD_SHARED)
 
     if(ZLIB_BUILD_STATIC)

From 7f849d109fcf2a8fdcf3cb62ff17c98b17585627 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Sun, 1 Dec 2024 08:52:43 +0100
Subject: [PATCH 007/128] CMake: Bump minimum version.

---
 CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ce5ce3547..cf6193cb8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.1)
+cmake_minimum_required(VERSION 3.5)
 set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
 
 project(zlib C)

From 6628a10f148d973a713b5fac63006a06aef1af27 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Sun, 1 Dec 2024 08:53:27 +0100
Subject: [PATCH 008/128] CMake: Move versionscript block to zlib definition.

---
 CMakeLists.txt | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index cf6193cb8..9c8630ee4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -165,6 +165,11 @@ if(ZLIB_BUILD_SHARED)
         SOVERSION 1
         PROPERTIES OUTPUT_NAME z
         PROPERTIES OUTPUT_NAME_DEBUG z${zlib_debug_suffix})
+    if(UNIX AND NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
+        # On unix-like platforms the library is almost always called libz
+        set_target_properties(zlib PROPERTIES
+            LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
+    endif(UNIX AND NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
 endif(ZLIB_BUILD_SHARED)
 
 if(ZLIB_BUILD_STATIC)
@@ -188,16 +193,6 @@ if(NOT CYGWIN AND ZLIB_BUILD_SHARED)
     set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
 endif()
 
-if(UNIX)
-    # On unix-like platforms the library is almost always called libz
-    if(ZLIB_BUILD_SHARED)
-        if(NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
-            set_target_properties(zlib PROPERTIES
-                LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
-        endif()
-    endif(ZLIB_BUILD_SHARED)
-endif()
-
 if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
     if(ZLIB_BUILD_SHARED)
         install(TARGETS zlib

From 76c6a8601cc1267a7198c5b6ecc6cfa207825e5b Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Sun, 1 Dec 2024 09:45:31 +0100
Subject: [PATCH 009/128] CMake: Set version in project call.

Use variables set by it.
---
 CMakeLists.txt | 57 +++++++++++++++++++++++++-------------------------
 1 file changed, 28 insertions(+), 29 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9c8630ee4..4a1b621b3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,9 +1,9 @@
 cmake_minimum_required(VERSION 3.5)
 set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
 
-project(zlib C)
-
-set(VERSION "1.3.1.1")
+project(zlib
+    LANGUAGES C
+    VERSION 1.3.1.1)
 
 option(ZLIB_BUILD_EXAMPLES "Enable Zlib Examples" ON)
 option(ZLIB_BUILD_SHARED "Enable building zlib shared library" ON)
@@ -62,28 +62,28 @@ check_include_file(unistd.h Z_HAVE_UNISTD_H)
 if(MSVC)
     add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
     add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
-    include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+    include_directories(${zlib_SOURCE_DIR})
 endif()
 
 option(RENAME_ZCONF "Rename the zconf when building out of source" ON)
-if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR AND RENAME_ZCONF)
+if(NOT zlib_SOURCE_DIR STREQUAL zlib_BINARY_DIR AND RENAME_ZCONF)
     # If we're doing an out of source build and the user has a zconf.h
     # in their source tree...
-    if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h)
+    if(EXISTS ${zlib_SOURCE_DIR}/zconf.h)
         message(STATUS "Renaming")
-        message(STATUS "    ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h")
+        message(STATUS "    ${zlib_SOURCE_DIR}/zconf.h")
         message(STATUS "to 'zconf.h.included' because this file is included with zlib")
         message(STATUS "but CMake generates it automatically in the build directory.")
-        file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included)
+        file(RENAME ${zlib_SOURCE_DIR}/zconf.h ${zlib_SOURCE_DIR}/zconf.h.included)
   endif()
 endif()
 
-set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc)
-configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein
+set(ZLIB_PC ${zlib_BINARY_DIR}/zlib.pc)
+configure_file( ${zlib_SOURCE_DIR}/zlib.pc.cmakein
 		${ZLIB_PC} @ONLY)
-configure_file(	${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
-		${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)
-include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
+configure_file(	${zlib_SOURCE_DIR}/zconf.h.cmakein
+		${zlib_BINARY_DIR}/zconf.h @ONLY)
+include_directories(${zlib_BINARY_DIR} ${zlib_SOURCE_DIR})
 
 
 #============================================================================
@@ -91,7 +91,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
 #============================================================================
 
 set(ZLIB_PUBLIC_HDRS
-    ${CMAKE_CURRENT_BINARY_DIR}/zconf.h
+    ${zlib_BINARY_DIR}/zconf.h
     zlib.h
 )
 set(ZLIB_PRIVATE_HDRS
@@ -130,24 +130,23 @@ if(NOT MINGW)
 endif()
 
 # parse the full version number from zlib.h and include in ZLIB_FULL_VERSION
-file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents)
+file(READ ${zlib_SOURCE_DIR}/zlib.h _zlib_h_contents)
 string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
-    "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})
-
+    "\\1" ZLIB_VERSION ${_zlib_h_contents})
 if(MINGW)
     # This gets us DLL resource information when compiling on MinGW.
     if(NOT CMAKE_RC_COMPILER)
         set(CMAKE_RC_COMPILER windres.exe)
     endif()
 
-    add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
+    add_custom_command(OUTPUT ${zlib_BINARY_DIR}/zlib1rc.obj
                        COMMAND ${CMAKE_RC_COMPILER}
                             -D GCC_WINDRES
-                            -I ${CMAKE_CURRENT_SOURCE_DIR}
-                            -I ${CMAKE_CURRENT_BINARY_DIR}
-                            -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
-                            -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
-    set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
+                            -I ${zlib_SOURCE_DIR}
+                            -I ${zlib_BINARY_DIR}
+                            -o ${zlib_BINARY_DIR}/zlib1rc.obj
+                            -i ${zlib_SOURCE_DIR}/win32/zlib1.rc)
+    set(ZLIB_DLL_SRCS ${zlib_BINARY_DIR}/zlib1rc.obj)
 endif(MINGW)
 
 if(WIN32)
@@ -158,8 +157,8 @@ endif(WIN32)
 if(ZLIB_BUILD_SHARED)
     add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
     target_include_directories(zlib PUBLIC
-        $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
-        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
+        $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
+        $<BUILD_INTERFACE:${zlib_SOURCE_DIR}>)
     set_target_properties(zlib PROPERTIES
         DEFINE_SYMBOL ZLIB_DLL
         SOVERSION 1
@@ -168,15 +167,15 @@ if(ZLIB_BUILD_SHARED)
     if(UNIX AND NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
         # On unix-like platforms the library is almost always called libz
         set_target_properties(zlib PROPERTIES
-            LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
+            LINK_FLAGS "-Wl,--version-script,\"${zlib_SOURCE_DIR}/zlib.map\"")
     endif(UNIX AND NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
 endif(ZLIB_BUILD_SHARED)
 
 if(ZLIB_BUILD_STATIC)
     add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
     target_include_directories(zlibstatic PUBLIC
-        $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
-        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
+        $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
+        $<BUILD_INTERFACE:${zlib_SOURCE_DIR}>)
     set_target_properties(zlibstatic PROPERTIES
         PROPERTIES OUTPUT_NAME z${zlib_static_suffix}
         PROPERTIES OUTPUT_NAME_DEBUG z${zlib_static_suffix}${zlib_debug_suffix})
@@ -190,7 +189,7 @@ if(NOT CYGWIN AND ZLIB_BUILD_SHARED)
     #
     # This has no effect with MSVC, on that platform the version info for
     # the DLL comes from the resource file win32/zlib1.rc
-    set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
+    set_target_properties(zlib PROPERTIES VERSION ${zlib_VERSION})
 endif()
 
 if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )

From 676246752388ad183594765a49f6b159c2a53db2 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Sun, 1 Dec 2024 09:49:36 +0100
Subject: [PATCH 010/128] CMake: Rename examples and tests to avoid chain
 building confusion.

---
 CMakeLists.txt | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4a1b621b3..4f2babc6b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -235,18 +235,18 @@ endif()
 # Example binaries
 #============================================================================
 if(ZLIB_BUILD_EXAMPLES)
-    add_executable(example test/example.c)
-    target_link_libraries(example zlib)
-    add_test(example example)
+    add_executable(zlib_example test/example.c)
+    target_link_libraries(zlib_example zlib)
+    add_test(zlib_example zlib_example)
 
     add_executable(minigzip test/minigzip.c)
     target_link_libraries(minigzip zlib)
 
     if(HAVE_OFF64_T)
-        add_executable(example64 test/example.c)
-        target_link_libraries(example64 zlib)
-        set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
-        add_test(example64 example64)
+        add_executable(zlib_example64 test/example.c)
+        target_link_libraries(zlib_example64 zlib)
+        set_target_properties(zlib_example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
+        add_test(zlib_example64 zlib_example64)
 
         add_executable(minigzip64 test/minigzip.c)
         target_link_libraries(minigzip64 zlib)

From 2b2eec69b52ae600441f6ffb2f545b7833caa842 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Sun, 1 Dec 2024 10:13:00 +0100
Subject: [PATCH 011/128] CMake: Remove unneeded renaming for in-tree builds
 and the option for it.

---
 CMakeLists.txt | 13 -------------
 1 file changed, 13 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4f2babc6b..814df1837 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -65,19 +65,6 @@ if(MSVC)
     include_directories(${zlib_SOURCE_DIR})
 endif()
 
-option(RENAME_ZCONF "Rename the zconf when building out of source" ON)
-if(NOT zlib_SOURCE_DIR STREQUAL zlib_BINARY_DIR AND RENAME_ZCONF)
-    # If we're doing an out of source build and the user has a zconf.h
-    # in their source tree...
-    if(EXISTS ${zlib_SOURCE_DIR}/zconf.h)
-        message(STATUS "Renaming")
-        message(STATUS "    ${zlib_SOURCE_DIR}/zconf.h")
-        message(STATUS "to 'zconf.h.included' because this file is included with zlib")
-        message(STATUS "but CMake generates it automatically in the build directory.")
-        file(RENAME ${zlib_SOURCE_DIR}/zconf.h ${zlib_SOURCE_DIR}/zconf.h.included)
-  endif()
-endif()
-
 set(ZLIB_PC ${zlib_BINARY_DIR}/zlib.pc)
 configure_file( ${zlib_SOURCE_DIR}/zlib.pc.cmakein
 		${ZLIB_PC} @ONLY)

From 902f6eedf31d198dcc47abb89a99f5cead9ad6f7 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Sun, 1 Dec 2024 11:23:35 +0100
Subject: [PATCH 012/128] CMake: Remove checks for sys/types.h, stdint.h and
 stddef.h.

This is done by check_type_size.
---
 CMakeLists.txt | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 814df1837..00fe4640f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,26 +20,11 @@ include(CheckCSourceCompiles)
 include(GNUInstallDirs)
 enable_testing()
 
-check_include_file(sys/types.h HAVE_SYS_TYPES_H)
-check_include_file(stdint.h    HAVE_STDINT_H)
-check_include_file(stddef.h    HAVE_STDDEF_H)
-
 #
 # Check to see if we have large file support
 #
 set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
-# We add these other definitions here because CheckTypeSize.cmake
-# in CMake 2.4.x does not automatically do so and we want
-# compatibility with CMake 2.4.x.
-if(HAVE_SYS_TYPES_H)
-    list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H)
-endif()
-if(HAVE_STDINT_H)
-    list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H)
-endif()
-if(HAVE_STDDEF_H)
-    list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
-endif()
+
 check_type_size(off64_t OFF64_T)
 if(HAVE_OFF64_T)
    add_definitions(-D_LARGEFILE64_SOURCE=1)

From feb7fd325a66d8bad361cd8e7107cecddeab1da6 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Sun, 1 Dec 2024 11:33:10 +0100
Subject: [PATCH 013/128] CMake: Remove doubled include directories.

---
 CMakeLists.txt | 1 -
 1 file changed, 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 00fe4640f..3a0e4d832 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -47,7 +47,6 @@ check_include_file(unistd.h Z_HAVE_UNISTD_H)
 if(MSVC)
     add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
     add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
-    include_directories(${zlib_SOURCE_DIR})
 endif()
 
 set(ZLIB_PC ${zlib_BINARY_DIR}/zlib.pc)

From 31d2462c1df539e6bb9bedc987ba991672a1906e Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Sun, 1 Dec 2024 16:52:59 +0100
Subject: [PATCH 014/128] CMake: Move compile_definitions to the targets.

---
 CMakeLists.txt | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3a0e4d832..20eaa9e1f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,31 +24,19 @@ enable_testing()
 # Check to see if we have large file support
 #
 set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
-
 check_type_size(off64_t OFF64_T)
-if(HAVE_OFF64_T)
-   add_definitions(-D_LARGEFILE64_SOURCE=1)
-endif()
 set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
 
 #
 # Check for fseeko
 #
 check_function_exists(fseeko HAVE_FSEEKO)
-if(NOT HAVE_FSEEKO)
-    add_definitions(-DNO_FSEEKO)
-endif()
 
 #
 # Check for unistd.h
 #
 check_include_file(unistd.h Z_HAVE_UNISTD_H)
 
-if(MSVC)
-    add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
-    add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
-endif()
-
 set(ZLIB_PC ${zlib_BINARY_DIR}/zlib.pc)
 configure_file( ${zlib_SOURCE_DIR}/zlib.pc.cmakein
 		${ZLIB_PC} @ONLY)
@@ -130,6 +118,12 @@ if(ZLIB_BUILD_SHARED)
     target_include_directories(zlib PUBLIC
         $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
         $<BUILD_INTERFACE:${zlib_SOURCE_DIR}>)
+    target_compile_definitions(zlib
+        PRIVATE
+            $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>
+            $<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
+            $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
+            $<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>)
     set_target_properties(zlib PROPERTIES
         DEFINE_SYMBOL ZLIB_DLL
         SOVERSION 1
@@ -147,6 +141,13 @@ if(ZLIB_BUILD_STATIC)
     target_include_directories(zlibstatic PUBLIC
         $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
         $<BUILD_INTERFACE:${zlib_SOURCE_DIR}>)
+    target_compile_definitions(zlibstatic
+        PRIVATE
+            $<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
+            $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
+            $<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>
+        PUBLIC
+            $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
     set_target_properties(zlibstatic PROPERTIES
         PROPERTIES OUTPUT_NAME z${zlib_static_suffix}
         PROPERTIES OUTPUT_NAME_DEBUG z${zlib_static_suffix}${zlib_debug_suffix})

From 899ef97c4a2ca0d9e27d3d91437f6da5e6eea218 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Sun, 1 Dec 2024 16:55:19 +0100
Subject: [PATCH 015/128] CMake: Use the same definition we checked for
 off64_t.

Move to target_compile_definitions.
---
 CMakeLists.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 20eaa9e1f..74bc1a93f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -216,12 +216,12 @@ if(ZLIB_BUILD_EXAMPLES)
 
     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)
-        set_target_properties(zlib_example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
         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)
-        set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
     endif()
 endif()

From 1af1bb6ce4b8e8d0b5b34985bafe7a8c3dd0e173 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Sun, 1 Dec 2024 16:56:09 +0100
Subject: [PATCH 016/128] CMake: Let cmake handle zlib1.rc.

---
 CMakeLists.txt | 39 ++++++++++++---------------------------
 1 file changed, 12 insertions(+), 27 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 74bc1a93f..7edfc34af 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -82,31 +82,8 @@ set(ZLIB_SRCS
     zutil.c
 )
 
-if(NOT MINGW)
-    set(ZLIB_DLL_SRCS
-        win32/zlib1.rc # If present will override custom build rule below.
-    )
-endif()
-
-# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION
-file(READ ${zlib_SOURCE_DIR}/zlib.h _zlib_h_contents)
-string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
-    "\\1" ZLIB_VERSION ${_zlib_h_contents})
-if(MINGW)
-    # This gets us DLL resource information when compiling on MinGW.
-    if(NOT CMAKE_RC_COMPILER)
-        set(CMAKE_RC_COMPILER windres.exe)
-    endif()
-
-    add_custom_command(OUTPUT ${zlib_BINARY_DIR}/zlib1rc.obj
-                       COMMAND ${CMAKE_RC_COMPILER}
-                            -D GCC_WINDRES
-                            -I ${zlib_SOURCE_DIR}
-                            -I ${zlib_BINARY_DIR}
-                            -o ${zlib_BINARY_DIR}/zlib1rc.obj
-                            -i ${zlib_SOURCE_DIR}/win32/zlib1.rc)
-    set(ZLIB_DLL_SRCS ${zlib_BINARY_DIR}/zlib1rc.obj)
-endif(MINGW)
+set_source_files_properties(win32/zlib1.rc PROPERTIES
+    COMPILE_FLAGS $<$<STREQUAL:${CMAKE_RC_OUTPUT_EXTENSION},.obj>:-DGCC_WINDRES>)
 
 if(WIN32)
     set (zlib_static_suffix "s")
@@ -114,7 +91,12 @@ if(WIN32)
 endif(WIN32)
 
 if(ZLIB_BUILD_SHARED)
-    add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
+    add_library(zlib SHARED
+        ${ZLIB_SRCS}
+        ${ZLIB_DLL_SRCS}
+        ${ZLIB_PUBLIC_HDRS}
+        ${ZLIB_PRIVATE_HDRS}
+        $<$<BOOL:${WIN32}>:win32/zlib1.rc>)
     target_include_directories(zlib PUBLIC
         $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
         $<BUILD_INTERFACE:${zlib_SOURCE_DIR}>)
@@ -137,7 +119,10 @@ if(ZLIB_BUILD_SHARED)
 endif(ZLIB_BUILD_SHARED)
 
 if(ZLIB_BUILD_STATIC)
-    add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
+    add_library(zlibstatic STATIC
+        ${ZLIB_SRCS}
+        ${ZLIB_PUBLIC_HDRS}
+        ${ZLIB_PRIVATE_HDRS})
     target_include_directories(zlibstatic PUBLIC
         $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
         $<BUILD_INTERFACE:${zlib_SOURCE_DIR}>)

From ffbbe01b6d1ca8550bf5a72a148ab02011dfa2f3 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Sun, 1 Dec 2024 17:01:56 +0100
Subject: [PATCH 017/128] CMake: Remove allowance for unclosed constructs.

---
 CMakeLists.txt | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7edfc34af..30d29790a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,4 @@
 cmake_minimum_required(VERSION 3.5)
-set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
 
 project(zlib
     LANGUAGES C
@@ -147,7 +146,7 @@ if(NOT CYGWIN AND ZLIB_BUILD_SHARED)
     # This has no effect with MSVC, on that platform the version info for
     # the DLL comes from the resource file win32/zlib1.rc
     set_target_properties(zlib PROPERTIES VERSION ${zlib_VERSION})
-endif()
+endif(NOT CYGWIN AND ZLIB_BUILD_SHARED)
 
 if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
     if(ZLIB_BUILD_SHARED)
@@ -177,16 +176,16 @@ if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
             ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
             LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
     endif(ZLIB_BUILD_STATIC)
-endif()
+endif(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
 if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
     install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
-endif()
+endif(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
 if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
     install(FILES zlib.3 DESTINATION "${CMAKE_INSTALL_MANDIR}/man3")
-endif()
+endif(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
 if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
     install(FILES ${ZLIB_PC} DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
-endif()
+endif(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
 
 #============================================================================
 # Example binaries
@@ -208,5 +207,5 @@ if(ZLIB_BUILD_EXAMPLES)
         add_executable(minigzip64 test/minigzip.c)
         target_compile_definitions(minigzip64 PRIVATE LARGEFILE64_SOURCE=1)
         target_link_libraries(minigzip64 zlib)
-    endif()
-endif()
+    endif(HAVE_OFF64_T)
+endif(ZLIB_BUILD_EXAMPLES)

From 64e8307d6a16e93703453e7e8024ec063a6f5665 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Sun, 1 Dec 2024 17:05:50 +0100
Subject: [PATCH 018/128] CMake: Make formatting consistent.

---
 CMakeLists.txt | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 30d29790a..191249639 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,21 +37,20 @@ check_function_exists(fseeko HAVE_FSEEKO)
 check_include_file(unistd.h Z_HAVE_UNISTD_H)
 
 set(ZLIB_PC ${zlib_BINARY_DIR}/zlib.pc)
-configure_file( ${zlib_SOURCE_DIR}/zlib.pc.cmakein
-		${ZLIB_PC} @ONLY)
-configure_file(	${zlib_SOURCE_DIR}/zconf.h.cmakein
-		${zlib_BINARY_DIR}/zconf.h @ONLY)
+configure_file(${zlib_SOURCE_DIR}/zlib.pc.cmakein
+               ${ZLIB_PC} @ONLY)
+configure_file(${zlib_SOURCE_DIR}/zconf.h.cmakein
+               ${zlib_BINARY_DIR}/zconf.h @ONLY)
 include_directories(${zlib_BINARY_DIR} ${zlib_SOURCE_DIR})
 
-
 #============================================================================
 # zlib
 #============================================================================
 
 set(ZLIB_PUBLIC_HDRS
     ${zlib_BINARY_DIR}/zconf.h
-    zlib.h
-)
+    zlib.h)
+
 set(ZLIB_PRIVATE_HDRS
     crc32.h
     deflate.h
@@ -61,8 +60,8 @@ set(ZLIB_PRIVATE_HDRS
     inflate.h
     inftrees.h
     trees.h
-    zutil.h
-)
+    zutil.h)
+
 set(ZLIB_SRCS
     adler32.c
     compress.c
@@ -78,8 +77,7 @@ set(ZLIB_SRCS
     inffast.c
     trees.c
     uncompr.c
-    zutil.c
-)
+    zutil.c)
 
 set_source_files_properties(win32/zlib1.rc PROPERTIES
     COMPILE_FLAGS $<$<STREQUAL:${CMAKE_RC_OUTPUT_EXTENSION},.obj>:-DGCC_WINDRES>)
@@ -148,7 +146,7 @@ if(NOT CYGWIN AND ZLIB_BUILD_SHARED)
     set_target_properties(zlib PROPERTIES VERSION ${zlib_VERSION})
 endif(NOT CYGWIN AND ZLIB_BUILD_SHARED)
 
-if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
+if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
     if(ZLIB_BUILD_SHARED)
         install(TARGETS zlib
             RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
@@ -176,16 +174,16 @@ if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
             ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
             LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
     endif(ZLIB_BUILD_STATIC)
-endif(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
-if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
+endif(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
+if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL)
     install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
 endif(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
 if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
     install(FILES zlib.3 DESTINATION "${CMAKE_INSTALL_MANDIR}/man3")
-endif(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
-if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
+endif(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL)
+if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL)
     install(FILES ${ZLIB_PC} DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
-endif(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
+endif(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL)
 
 #============================================================================
 # Example binaries

From c18815b63074960573af9598c93fa968babb52ed Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Sun, 1 Dec 2024 17:37:47 +0100
Subject: [PATCH 019/128] CMake: Simplify to one install option.

What to install is chosen with components.
---
 CMakeLists.txt | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 191249639..54b3f24fc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,6 +7,7 @@ project(zlib
 option(ZLIB_BUILD_EXAMPLES "Enable Zlib Examples" ON)
 option(ZLIB_BUILD_SHARED "Enable building zlib shared library" ON)
 option(ZLIB_BUILD_STATIC "Enable building zlib static library" ON)
+option(ZLIB_INSTALL_LIBRARIES "Enable installation of zlib" ON)
 
 if(WIN32)
     option(ZLIB_INSTALL_COMPAT_DLL "Install a copy as zlib1.dll" ON)
@@ -146,44 +147,48 @@ if(NOT CYGWIN AND ZLIB_BUILD_SHARED)
     set_target_properties(zlib PROPERTIES VERSION ${zlib_VERSION})
 endif(NOT CYGWIN AND ZLIB_BUILD_SHARED)
 
-if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
+if(ZLIB_INSTALL_LIBRARIES)
     if(ZLIB_BUILD_SHARED)
         install(TARGETS zlib
+            COMPONENT Runtime
             RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
             ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
             LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
         if(ZLIB_INSTALL_COMPAT_DLL)
             install(FILES  $<TARGET_FILE:zlib>
+                COMPONENT Runtime
                 RENAME zlib1.dll
                 DESTINATION "${CMAKE_INSTALL_BINDIR}")
         endif(ZLIB_INSTALL_COMPAT_DLL)
 
         if(MSVC)
             install(FILES $<TARGET_PDB_FILE:zlib>
+                COMPONENT Runtime
                 DESTINATION ${CMAKE_INSTALL_BINDIR}
                 CONFIGURATIONS Debug OR RelWithDebInfo
                 OPTIONAL
             )
         endif(MSVC)
-
     endif(ZLIB_BUILD_SHARED)
 
     if(ZLIB_BUILD_STATIC)
         install(TARGETS zlibstatic
+            COMPONENT Development
             RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
             ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
             LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
     endif(ZLIB_BUILD_STATIC)
-endif(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
-if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL)
-    install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
-endif(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
-if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
-    install(FILES zlib.3 DESTINATION "${CMAKE_INSTALL_MANDIR}/man3")
-endif(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL)
-if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL)
-    install(FILES ${ZLIB_PC} DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
-endif(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL)
+
+    install(FILES ${ZLIB_PUBLIC_HDRS}
+            COMPONENT Development
+            DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
+        FILES zlib.3
+            COMPONENT Development
+            DESTINATION "${CMAKE_INSTALL_MANDIR}/man3"
+        FILES ${ZLIB_PC}
+            COMPONENT Development
+            DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
+endif(ZLIB_INSTALL_LIBRARIES)
 
 #============================================================================
 # Example binaries

From b6cb6f4c213d9a8d58f996552d2652baa5ee550d Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Sun, 1 Dec 2024 17:48:11 +0100
Subject: [PATCH 020/128] CMake: Rename examples to testing to reflect their
 intent.

---
 CMakeLists.txt | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 54b3f24fc..3cd986b7c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,7 +4,7 @@ project(zlib
     LANGUAGES C
     VERSION 1.3.1.1)
 
-option(ZLIB_BUILD_EXAMPLES "Enable Zlib Examples" ON)
+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_INSTALL_LIBRARIES "Enable installation of zlib" ON)
@@ -193,7 +193,8 @@ endif(ZLIB_INSTALL_LIBRARIES)
 #============================================================================
 # Example binaries
 #============================================================================
-if(ZLIB_BUILD_EXAMPLES)
+if(ZLIB_BUILD_TESTING)
+    enable_testing()
     add_executable(zlib_example test/example.c)
     target_link_libraries(zlib_example zlib)
     add_test(zlib_example zlib_example)
@@ -211,4 +212,4 @@ if(ZLIB_BUILD_EXAMPLES)
         target_compile_definitions(minigzip64 PRIVATE LARGEFILE64_SOURCE=1)
         target_link_libraries(minigzip64 zlib)
     endif(HAVE_OFF64_T)
-endif(ZLIB_BUILD_EXAMPLES)
+endif(ZLIB_BUILD_TESTING)

From c33f3bc641f327adb65b2c98b1cdb166c9860e9d Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Sun, 1 Dec 2024 17:49:30 +0100
Subject: [PATCH 021/128] CMake: Move version setting for Cygwin into
 set_target_properties.

---
 CMakeLists.txt | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3cd986b7c..28a4c3f5c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,7 +18,6 @@ include(CheckFunctionExists)
 include(CheckIncludeFile)
 include(CheckCSourceCompiles)
 include(GNUInstallDirs)
-enable_testing()
 
 #
 # Check to see if we have large file support
@@ -104,11 +103,19 @@ if(ZLIB_BUILD_SHARED)
             $<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
             $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
             $<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>)
+    # The VERSION property causes shared libraries on Linux to have the full version
+    # encoded into their final filename.  We disable this on Cygwin because
+    # it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll
+    # seems to be the default.
+    #
+    # This has no effect with MSVC, on that platform the version info for
+    # the DLL comes from the resource file win32/zlib1.rc
     set_target_properties(zlib PROPERTIES
         DEFINE_SYMBOL ZLIB_DLL
         SOVERSION 1
         PROPERTIES OUTPUT_NAME z
-        PROPERTIES OUTPUT_NAME_DEBUG z${zlib_debug_suffix})
+        PROPERTIES OUTPUT_NAME_DEBUG z${zlib_debug_suffix}
+        $<$<BOOL:NOT:$CYGWIN}>:VERSION ${zlib_VERSION}>)
     if(UNIX AND NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
         # On unix-like platforms the library is almost always called libz
         set_target_properties(zlib PROPERTIES
@@ -136,17 +143,6 @@ if(ZLIB_BUILD_STATIC)
         PROPERTIES OUTPUT_NAME_DEBUG z${zlib_static_suffix}${zlib_debug_suffix})
 endif(ZLIB_BUILD_STATIC)
 
-if(NOT CYGWIN AND ZLIB_BUILD_SHARED)
-    # This property causes shared libraries on Linux to have the full version
-    # encoded into their final filename.  We disable this on Cygwin because
-    # it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll
-    # seems to be the default.
-    #
-    # This has no effect with MSVC, on that platform the version info for
-    # the DLL comes from the resource file win32/zlib1.rc
-    set_target_properties(zlib PROPERTIES VERSION ${zlib_VERSION})
-endif(NOT CYGWIN AND ZLIB_BUILD_SHARED)
-
 if(ZLIB_INSTALL_LIBRARIES)
     if(ZLIB_BUILD_SHARED)
         install(TARGETS zlib

From 48b9ee48caddc4ddfa3f5b9ebad3a8610df8d5be Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Mon, 2 Dec 2024 15:07:40 +0100
Subject: [PATCH 022/128] CMake: Use CMAKE_DEBUG_POSTFIX for simplification.

---
 CMakeLists.txt | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 28a4c3f5c..f428458cb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -83,8 +83,8 @@ set_source_files_properties(win32/zlib1.rc PROPERTIES
     COMPILE_FLAGS $<$<STREQUAL:${CMAKE_RC_OUTPUT_EXTENSION},.obj>:-DGCC_WINDRES>)
 
 if(WIN32)
-    set (zlib_static_suffix "s")
-    set (zlib_debug_suffix "d")
+    set(zlib_static_suffix "s")
+    set(CMAKE_DEBUG_POSTFIX "d")
 endif(WIN32)
 
 if(ZLIB_BUILD_SHARED)
@@ -112,9 +112,8 @@ if(ZLIB_BUILD_SHARED)
     # the DLL comes from the resource file win32/zlib1.rc
     set_target_properties(zlib PROPERTIES
         DEFINE_SYMBOL ZLIB_DLL
+        OUTPUT_NAME z
         SOVERSION 1
-        PROPERTIES OUTPUT_NAME z
-        PROPERTIES OUTPUT_NAME_DEBUG z${zlib_debug_suffix}
         $<$<BOOL:NOT:$CYGWIN}>:VERSION ${zlib_VERSION}>)
     if(UNIX AND NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
         # On unix-like platforms the library is almost always called libz
@@ -139,8 +138,8 @@ if(ZLIB_BUILD_STATIC)
         PUBLIC
             $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
     set_target_properties(zlibstatic PROPERTIES
-        PROPERTIES OUTPUT_NAME z${zlib_static_suffix}
-        PROPERTIES OUTPUT_NAME_DEBUG z${zlib_static_suffix}${zlib_debug_suffix})
+        EXPORT_NAME ZLIBSTATIC
+        OUTPUT_NAME z${zlib_static_suffix})
 endif(ZLIB_BUILD_STATIC)
 
 if(ZLIB_INSTALL_LIBRARIES)

From 633ec876779b32f777e33574b65e41d2bbdec72f Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Mon, 2 Dec 2024 15:08:19 +0100
Subject: [PATCH 023/128] CMake: Add zlib1.rc to Cygwin build.

---
 CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f428458cb..efa0ef4a6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -93,7 +93,7 @@ if(ZLIB_BUILD_SHARED)
         ${ZLIB_DLL_SRCS}
         ${ZLIB_PUBLIC_HDRS}
         ${ZLIB_PRIVATE_HDRS}
-        $<$<BOOL:${WIN32}>:win32/zlib1.rc>)
+        $<$<OR:$<BOOL:${WIN32}>,$<BOOL:${CYGWIN}>>:win32/zlib1.rc>)
     target_include_directories(zlib PUBLIC
         $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
         $<BUILD_INTERFACE:${zlib_SOURCE_DIR}>)

From f0175c69e216545ff543b1f46870d1c1a27aa5f0 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Mon, 2 Dec 2024 15:09:17 +0100
Subject: [PATCH 024/128] CMake: Add INSTALL_INTERFACE for a proper export.

---
 CMakeLists.txt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index efa0ef4a6..3b24374ae 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -96,7 +96,8 @@ if(ZLIB_BUILD_SHARED)
         $<$<OR:$<BOOL:${WIN32}>,$<BOOL:${CYGWIN}>>:win32/zlib1.rc>)
     target_include_directories(zlib PUBLIC
         $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
-        $<BUILD_INTERFACE:${zlib_SOURCE_DIR}>)
+        $<BUILD_INTERFACE:${zlib_SOURCE_DIR}>
+        $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
     target_compile_definitions(zlib
         PRIVATE
             $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>
@@ -129,7 +130,8 @@ if(ZLIB_BUILD_STATIC)
         ${ZLIB_PRIVATE_HDRS})
     target_include_directories(zlibstatic PUBLIC
         $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
-        $<BUILD_INTERFACE:${zlib_SOURCE_DIR}>)
+        $<BUILD_INTERFACE:${zlib_SOURCE_DIR}>
+        $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
     target_compile_definitions(zlibstatic
         PRIVATE
             $<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>

From f7ab6e43732bc68b38ef5db5feda27105d954b5b Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Mon, 2 Dec 2024 15:11:31 +0100
Subject: [PATCH 025/128] CMake: Add aliases to match the export names.

---
 CMakeLists.txt | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3b24374ae..79009627c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -94,6 +94,7 @@ if(ZLIB_BUILD_SHARED)
         ${ZLIB_PUBLIC_HDRS}
         ${ZLIB_PRIVATE_HDRS}
         $<$<OR:$<BOOL:${WIN32}>,$<BOOL:${CYGWIN}>>:win32/zlib1.rc>)
+    add_library(ZLIB::ZLIB ALIAS zlib)
     target_include_directories(zlib PUBLIC
         $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
         $<BUILD_INTERFACE:${zlib_SOURCE_DIR}>
@@ -113,6 +114,7 @@ if(ZLIB_BUILD_SHARED)
     # the DLL comes from the resource file win32/zlib1.rc
     set_target_properties(zlib PROPERTIES
         DEFINE_SYMBOL ZLIB_DLL
+        EXPORT_NAME ZLIB
         OUTPUT_NAME z
         SOVERSION 1
         $<$<BOOL:NOT:$CYGWIN}>:VERSION ${zlib_VERSION}>)
@@ -128,6 +130,7 @@ if(ZLIB_BUILD_STATIC)
         ${ZLIB_SRCS}
         ${ZLIB_PUBLIC_HDRS}
         ${ZLIB_PRIVATE_HDRS})
+    add_library(ZLIB::ZLIBSTATIC ALIAS zlibstatic)
     target_include_directories(zlibstatic PUBLIC
         $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
         $<BUILD_INTERFACE:${zlib_SOURCE_DIR}>
@@ -193,20 +196,20 @@ endif(ZLIB_INSTALL_LIBRARIES)
 if(ZLIB_BUILD_TESTING)
     enable_testing()
     add_executable(zlib_example test/example.c)
-    target_link_libraries(zlib_example zlib)
+    target_link_libraries(zlib_example ZLIB::ZLIB)
     add_test(zlib_example zlib_example)
 
     add_executable(minigzip test/minigzip.c)
-    target_link_libraries(minigzip zlib)
+    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)
+        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)
+        target_link_libraries(minigzip64 ZLIB::ZLIB)
     endif(HAVE_OFF64_T)
 endif(ZLIB_BUILD_TESTING)

From e37a1a8345420989d20f555102d5bef4cb116b86 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Tue, 3 Dec 2024 13:44:06 +0100
Subject: [PATCH 026/128] CMake: Warn if no build-type is selected.

---
 CMakeLists.txt | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 79009627c..b20a7eff2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.5)
+cmake_minimum_required(VERSION 3.9)
 
 project(zlib
     LANGUAGES C
@@ -13,6 +13,13 @@ if(WIN32)
     option(ZLIB_INSTALL_COMPAT_DLL "Install a copy as zlib1.dll" ON)
 endif(WIN32)
 
+get_property(IS_MULTI GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+
+if(NOT DEFINED CMAKE_BUILD_TYPE AND NOT IS_MULTI)
+    message(STATUS "No CMAKE_BUILD_TYPE set -- using Release")
+    set(CMAKE_BUILD_TYPE Release)
+endif(NOT DEFINED CMAKE_BUILD_TYPE AND NOT IS_MULTI)
+
 include(CheckTypeSize)
 include(CheckFunctionExists)
 include(CheckIncludeFile)

From f4624f3f032fefefe49e6bfd89fb7a3191abf3f9 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Tue, 3 Dec 2024 13:45:14 +0100
Subject: [PATCH 027/128] CMake: Add zlibExport.

---
 CMakeLists.txt      | 23 +++++++++++++++++++++++
 zlibConfig.cmake.in |  2 ++
 2 files changed, 25 insertions(+)
 create mode 100644 zlibConfig.cmake.in

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b20a7eff2..f474a5f09 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,6 +24,7 @@ include(CheckTypeSize)
 include(CheckFunctionExists)
 include(CheckIncludeFile)
 include(CheckCSourceCompiles)
+include(CMakePackageConfigHelpers)
 include(GNUInstallDirs)
 
 #
@@ -158,6 +159,7 @@ if(ZLIB_INSTALL_LIBRARIES)
     if(ZLIB_BUILD_SHARED)
         install(TARGETS zlib
             COMPONENT Runtime
+            EXPORT zlibExport
             RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
             ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
             LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
@@ -181,11 +183,32 @@ if(ZLIB_INSTALL_LIBRARIES)
     if(ZLIB_BUILD_STATIC)
         install(TARGETS zlibstatic
             COMPONENT Development
+            EXPORT zlibExport
             RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
             ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
             LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
     endif(ZLIB_BUILD_STATIC)
 
+    configure_package_config_file(${zlib_SOURCE_DIR}/zlibConfig.cmake.in
+        ${zlib_BINARY_DIR}/zlibConfig.cmake
+        INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib
+        NO_CHECK_REQUIRED_COMPONENTS_MACRO)
+
+    write_basic_package_version_file(
+        "${zlib_BINARY_DIR}/zlibConfigVersion.cmake"
+        VERSION "${zlib_VERSION}"
+        COMPATIBILITY AnyNewerVersion)
+
+    install(FILES
+        ${zlib_BINARY_DIR}/zlibConfig.cmake
+        ${zlib_BINARY_DIR}/zlibConfigVersion.cmake
+        DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
+
+    install(EXPORT zlibExport
+        FILE zlib.cmake
+        DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib
+        NAMESPACE ZLIB::)
+
     install(FILES ${ZLIB_PUBLIC_HDRS}
             COMPONENT Development
             DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
diff --git a/zlibConfig.cmake.in b/zlibConfig.cmake.in
new file mode 100644
index 000000000..aa11011ec
--- /dev/null
+++ b/zlibConfig.cmake.in
@@ -0,0 +1,2 @@
+@PACKAGE_INIT@
+INCLUDE (${CMAKE_CURRENT_LIST_DIR}/zlib.cmake)

From a794225144c335a0efe5a97ef7013746613eea46 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Tue, 3 Dec 2024 13:45:44 +0100
Subject: [PATCH 028/128] CMake: Permit install to put different things in
 different places.

---
 CMakeLists.txt | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f474a5f09..a4a043935 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -211,11 +211,11 @@ if(ZLIB_INSTALL_LIBRARIES)
 
     install(FILES ${ZLIB_PUBLIC_HDRS}
             COMPONENT Development
-            DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
-        FILES zlib.3
+            DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
+    install(FILES zlib.3
             COMPONENT Development
-            DESTINATION "${CMAKE_INSTALL_MANDIR}/man3"
-        FILES ${ZLIB_PC}
+            DESTINATION "${CMAKE_INSTALL_MANDIR}/man3")
+    install(FILES ${ZLIB_PC}
             COMPONENT Development
             DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
 endif(ZLIB_INSTALL_LIBRARIES)

From 7dc2b782067d746aac2a348e411004135fb5fbda Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Tue, 3 Dec 2024 15:23:19 +0100
Subject: [PATCH 029/128] CMake: Add test for usage with find_package.

---
 CMakeLists.txt                  |  2 ++
 test/CMakeLists.txt             | 44 +++++++++++++++++++++++++++++++++
 test/find_package_test.cmake.in | 24 ++++++++++++++++++
 3 files changed, 70 insertions(+)
 create mode 100644 test/CMakeLists.txt
 create mode 100644 test/find_package_test.cmake.in

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a4a043935..545dafe63 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -242,4 +242,6 @@ if(ZLIB_BUILD_TESTING)
         target_compile_definitions(minigzip64 PRIVATE LARGEFILE64_SOURCE=1)
         target_link_libraries(minigzip64 ZLIB::ZLIB)
     endif(HAVE_OFF64_T)
+
+    add_subdirectory(test)
 endif(ZLIB_BUILD_TESTING)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644
index 000000000..4758230ce
--- /dev/null
+++ b/test/CMakeLists.txt
@@ -0,0 +1,44 @@
+add_test(NAME zlib_test_install
+    COMMAND ${CMAKE_COMMAND} --install ${zlib_BINARY_DIR}
+        --prefix ${CMAKE_CURRENT_BINARY_DIR}/test_install
+        --config $<CONFIG>
+    WORKING_DIRECTORY ${zlib_BINARY_DIR})
+
+file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/find_package_test.cmake.in
+    ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test/CMakeLists.txt)
+
+add_test(NAME zlib_test_configure_find_package
+   COMMAND ${CMAKE_COMMAND}
+       -B${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build
+       -DCMAKE_BUILD_TYPE=$<CONFIG>
+       -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 zlib_test_build_find_package
+    COMMAND ${CMAKE_COMMAND} --build
+            ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build
+    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
+
+add_test(NAME zlib_test_test_find_package
+    COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
+    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
+
+set_tests_properties(zlib_test_install PROPERTIES
+    FIXTURES_SETUP install)
+
+set_tests_properties(zlib_test_configure_find_package PROPERTIES
+    FIXTURES_REQUIRED install
+    FIXTURES_SETUP config)
+
+set_tests_properties(zlib_test_build_find_package PROPERTIES
+    FIXTURES_REQUIRED config
+    FIXTURES_SETUP build)
+
+set_tests_properties(zlib_test_test_find_package PROPERTIES
+    FIXTURES_REQUIRED build)
diff --git a/test/find_package_test.cmake.in b/test/find_package_test.cmake.in
new file mode 100644
index 000000000..c1c11d012
--- /dev/null
+++ b/test/find_package_test.cmake.in
@@ -0,0 +1,24 @@
+cmake_minimum_required(VERSION 3.5)
+
+project(zlib_find_package_test
+    LANGUAGES C
+    VERSION 1.3.1.1)
+
+enable_testing()
+find_package(zlib 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})

From 1fce5f2cdf7849c4e4116488bbb0927bf80a7f1b Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 4 Dec 2024 17:12:37 +0100
Subject: [PATCH 030/128] CMake: Add more tests.

---
 test/CMakeLists.txt                         | 83 +++++++++++++++++++--
 test/add_subdirectory_exclude_test.cmake.in | 25 +++++++
 test/add_subdirectory_test.cmake.in         | 25 +++++++
 test/find_package_test.cmake.in             |  4 +-
 4 files changed, 130 insertions(+), 7 deletions(-)
 create mode 100644 test/add_subdirectory_exclude_test.cmake.in
 create mode 100644 test/add_subdirectory_test.cmake.in

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 4758230ce..de7c578ae 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -5,10 +5,22 @@ add_test(NAME zlib_test_install
     WORKING_DIRECTORY ${zlib_BINARY_DIR})
 
 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)
+
+#
+# findpackage_test
+#
 add_test(NAME zlib_test_configure_find_package
    COMMAND ${CMAKE_COMMAND}
        -B${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build
@@ -19,7 +31,6 @@ add_test(NAME zlib_test_configure_find_package
        -G "${CMAKE_GENERATOR}"
        -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
 
-
 add_test(NAME zlib_test_build_find_package
     COMMAND ${CMAKE_COMMAND} --build
             ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build
@@ -34,11 +45,73 @@ set_tests_properties(zlib_test_install PROPERTIES
 
 set_tests_properties(zlib_test_configure_find_package PROPERTIES
     FIXTURES_REQUIRED install
-    FIXTURES_SETUP config)
+    FIXTURES_SETUP fp_config)
 
 set_tests_properties(zlib_test_build_find_package PROPERTIES
-    FIXTURES_REQUIRED config
-    FIXTURES_SETUP build)
+    FIXTURES_REQUIRED fp_config
+    FIXTURES_SETUP fp_build)
 
 set_tests_properties(zlib_test_test_find_package PROPERTIES
-    FIXTURES_REQUIRED build)
+    FIXTURES_REQUIRED fp_build)
+
+#
+# add_subdirectory_test
+#
+add_test(NAME zlib_test_configure_add_subdirectory
+   COMMAND ${CMAKE_COMMAND}
+       -B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectoy_test_build
+       -DCMAKE_BUILD_TYPE=$<CONFIG>
+       -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_install
+       --fresh
+       -G "${CMAKE_GENERATOR}"
+       -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
+
+add_test(NAME zlib_test_build_add_subdirectory
+    COMMAND ${CMAKE_COMMAND} --build
+            ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectoy_test_build
+    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectoy_test_build)
+
+add_test(NAME zlib_test_test_add_subdirectory
+    COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
+    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectoy_test_build)
+
+set_tests_properties(zlib_test_configure_add_subdirectory PROPERTIES
+    FIXTURES_SETUP as_config)
+
+set_tests_properties(zlib_test_build_add_subdirectory PROPERTIES
+    FIXTURES_REQUIRED as_config
+    FIXTURES_SETUP as_build)
+
+set_tests_properties(zlib_test_test_add_subdirectory PROPERTIES
+    FIXTURES_REQUIRED as_build)
+
+#
+# add_subdirectory_exclude_test
+#
+add_test(NAME zlib_test_configure_add_subdirectory_exclude
+   COMMAND ${CMAKE_COMMAND}
+       -B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectoy_exclude_test_build
+       -DCMAKE_BUILD_TYPE=$<CONFIG>
+       -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_install
+       --fresh
+       -G "${CMAKE_GENERATOR}"
+       -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
+
+add_test(NAME zlib_test_build_add_subdirectory_exclude
+    COMMAND ${CMAKE_COMMAND} --build
+            ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectoy_exclude_test_build
+    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectoy_exclude_test_build)
+
+add_test(NAME zlib_test_test_add_subdirectory_exclude
+    COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
+    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectoy_exclude_test_build)
+
+set_tests_properties(zlib_test_configure_add_subdirectory_exclude PROPERTIES
+    FIXTURES_SETUP asx_config)
+
+set_tests_properties(zlib_test_build_add_subdirectory_exclude PROPERTIES
+    FIXTURES_REQUIRED as_config
+    FIXTURES_SETUP asx_build)
+
+set_tests_properties(zlib_test_test_add_subdirectory_exclude PROPERTIES
+    FIXTURES_REQUIRED asx_build)
diff --git a/test/add_subdirectory_exclude_test.cmake.in b/test/add_subdirectory_exclude_test.cmake.in
new file mode 100644
index 000000000..9dd9d35e7
--- /dev/null
+++ b/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/test/add_subdirectory_test.cmake.in b/test/add_subdirectory_test.cmake.in
new file mode 100644
index 000000000..c10f7095c
--- /dev/null
+++ b/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/test/find_package_test.cmake.in b/test/find_package_test.cmake.in
index c1c11d012..42f3c19e7 100644
--- a/test/find_package_test.cmake.in
+++ b/test/find_package_test.cmake.in
@@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 3.5)
 
 project(zlib_find_package_test
     LANGUAGES C
-    VERSION 1.3.1.1)
+    VERSION ${zlib_VERSION})
 
 enable_testing()
-find_package(zlib CONFIG REQUIRED)
+find_package(zlib ${zlib_VERSION} CONFIG REQUIRED)
 
 if(${ZLIB_BUILD_SHARED})
     add_executable(test_example ${zlib_SOURCE_DIR}/test/example.c)

From 6084c550c310caf265156ea0c33bf6febf58e313 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Thu, 5 Dec 2024 11:10:23 +0100
Subject: [PATCH 031/128] CMake: Set the platform and configuration for the
 tests.

---
 test/CMakeLists.txt | 73 +++++++++++++++++++++++++--------------------
 1 file changed, 41 insertions(+), 32 deletions(-)

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index de7c578ae..c749e20d4 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -18,22 +18,29 @@ configure_file(
 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 zlib_test_configure_find_package
-   COMMAND ${CMAKE_COMMAND}
-       -B${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build
-       -DCMAKE_BUILD_TYPE=$<CONFIG>
-       -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)
+    COMMAND ${CMAKE_COMMAND}
+        ${PLATFORM}
+        -B${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build
+        -DCMAKE_BUILD_TYPE=$<CONFIG>
+        -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 zlib_test_build_find_package
-    COMMAND ${CMAKE_COMMAND} --build
-            ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build
+    COMMAND ${CMAKE_COMMAND} --build .
+    --config $<CONFIG>
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
 
 add_test(NAME zlib_test_test_find_package
@@ -58,22 +65,23 @@ set_tests_properties(zlib_test_test_find_package PROPERTIES
 # add_subdirectory_test
 #
 add_test(NAME zlib_test_configure_add_subdirectory
-   COMMAND ${CMAKE_COMMAND}
-       -B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectoy_test_build
-       -DCMAKE_BUILD_TYPE=$<CONFIG>
-       -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_install
-       --fresh
-       -G "${CMAKE_GENERATOR}"
-       -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
+    COMMAND ${CMAKE_COMMAND}
+    ${PLATFORM}
+    -B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build
+    -DCMAKE_BUILD_TYPE=$<CONFIG>
+    -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_install
+    --fresh
+    -G "${CMAKE_GENERATOR}"
+    -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
 
 add_test(NAME zlib_test_build_add_subdirectory
-    COMMAND ${CMAKE_COMMAND} --build
-            ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectoy_test_build
-    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectoy_test_build)
+    COMMAND ${CMAKE_COMMAND} --build .
+    --config $<CONFIG>
+    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
 
 add_test(NAME zlib_test_test_add_subdirectory
     COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
-    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectoy_test_build)
+    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
 
 set_tests_properties(zlib_test_configure_add_subdirectory PROPERTIES
     FIXTURES_SETUP as_config)
@@ -89,22 +97,23 @@ set_tests_properties(zlib_test_test_add_subdirectory PROPERTIES
 # add_subdirectory_exclude_test
 #
 add_test(NAME zlib_test_configure_add_subdirectory_exclude
-   COMMAND ${CMAKE_COMMAND}
-       -B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectoy_exclude_test_build
-       -DCMAKE_BUILD_TYPE=$<CONFIG>
-       -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_install
-       --fresh
-       -G "${CMAKE_GENERATOR}"
-       -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
+    COMMAND ${CMAKE_COMMAND}
+    ${PLATFORM}
+    -B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build
+    -DCMAKE_BUILD_TYPE=$<CONFIG>
+    -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_install
+    --fresh
+    -G "${CMAKE_GENERATOR}"
+    -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
 
 add_test(NAME zlib_test_build_add_subdirectory_exclude
-    COMMAND ${CMAKE_COMMAND} --build
-            ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectoy_exclude_test_build
-    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectoy_exclude_test_build)
+    COMMAND ${CMAKE_COMMAND} --build .
+    --config $<CONFIG>
+    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
 
 add_test(NAME zlib_test_test_add_subdirectory_exclude
     COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
-    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectoy_exclude_test_build)
+    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
 
 set_tests_properties(zlib_test_configure_add_subdirectory_exclude PROPERTIES
     FIXTURES_SETUP asx_config)

From 4d74e4498eae2e4f527e67c0115ff2ec46923193 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Thu, 5 Dec 2024 11:10:55 +0100
Subject: [PATCH 032/128] CMake: Add the version to the exported configuration.

---
 zlibConfig.cmake.in | 1 +
 1 file changed, 1 insertion(+)

diff --git a/zlibConfig.cmake.in b/zlibConfig.cmake.in
index aa11011ec..dfe6bbaed 100644
--- a/zlibConfig.cmake.in
+++ b/zlibConfig.cmake.in
@@ -1,2 +1,3 @@
+set(zlib_VERSION @zlib_VERSION@)
 @PACKAGE_INIT@
 INCLUDE (${CMAKE_CURRENT_LIST_DIR}/zlib.cmake)

From 01ef679251f7045f20fa45d7f0b1b662c5d91682 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Thu, 5 Dec 2024 11:31:22 +0100
Subject: [PATCH 033/128] CMake: Pass CC and CFLAGS to the tests.

---
 test/CMakeLists.txt | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index c749e20d4..235ae5ef3 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -32,6 +32,8 @@ add_test(NAME zlib_test_configure_find_package
         ${PLATFORM}
         -B${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build
         -DCMAKE_BUILD_TYPE=$<CONFIG>
+        -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
@@ -69,6 +71,8 @@ add_test(NAME zlib_test_configure_add_subdirectory
     ${PLATFORM}
     -B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build
     -DCMAKE_BUILD_TYPE=$<CONFIG>
+    -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}"
@@ -101,6 +105,8 @@ add_test(NAME zlib_test_configure_add_subdirectory_exclude
     ${PLATFORM}
     -B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build
     -DCMAKE_BUILD_TYPE=$<CONFIG>
+    -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}"

From 494830e2dfcff18f014abc2b289d6b83ddc8c222 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Thu, 5 Dec 2024 11:39:40 +0100
Subject: [PATCH 034/128] CMake: Remove use of ZLIB_BUILD_EXAMPLES option in
 workflow.

---
 .github/workflows/c-std.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/c-std.yml b/.github/workflows/c-std.yml
index 44417bfad..8377db4ee 100644
--- a/.github/workflows/c-std.yml
+++ b/.github/workflows/c-std.yml
@@ -133,7 +133,7 @@ jobs:
     - name: Generate project files (cmake)
       if: matrix.builder == 'cmake'
       run: |
-        cmake -S . -B . -D CMAKE_BUILD_TYPE=Release -D ZLIB_BUILD_EXAMPLES=OFF  ${{ matrix.os.cmake-opt }}
+        cmake -S . -B . -D CMAKE_BUILD_TYPE=Release ${{ matrix.os.cmake-opt }}
       env:
         CC: ${{ matrix.compiler }}
         CFLAGS: -std=${{ matrix.std.value }} ${{ matrix.arch.compiler-opt }} -Werror -Wall -Wextra
@@ -205,4 +205,4 @@ jobs:
       run: cmake --build . --config Release -v
 
     - name: Run test cases (cmake)
-      run: ctest -C Release --output-on-failure --max-width 120
\ No newline at end of file
+      run: ctest -C Release --output-on-failure --max-width 120

From e0b78cea4f5e526da33eeebfaa0d06a6fcd70aee Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Thu, 5 Dec 2024 12:31:33 +0100
Subject: [PATCH 035/128] CMake: Name the shared library cygz.dll on Cygwin.

---
 CMakeLists.txt | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 545dafe63..4aaf62baf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -113,19 +113,18 @@ if(ZLIB_BUILD_SHARED)
             $<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
             $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
             $<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>)
-    # The VERSION property causes shared libraries on Linux to have the full version
-    # encoded into their final filename.  We disable this on Cygwin because
-    # it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll
-    # seems to be the default.
-    #
-    # This has no effect with MSVC, on that platform the version info for
-    # the DLL comes from the resource file win32/zlib1.rc
+    set(INSTALL_VERSION ${zlib_VERSION_MAJOR})
+
+    if(NOT CYGWIN)
+        set_target_properties(zlib PROPERTIES
+            SOVERSION ${zlib_VERSION_MAJOR}
+            VERSION ${INSTALL_VERSION})
+    endif(NOT CYGWIN)
+
     set_target_properties(zlib PROPERTIES
         DEFINE_SYMBOL ZLIB_DLL
         EXPORT_NAME ZLIB
-        OUTPUT_NAME z
-        SOVERSION 1
-        $<$<BOOL:NOT:$CYGWIN}>:VERSION ${zlib_VERSION}>)
+        OUTPUT_NAME z)
     if(UNIX AND NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
         # On unix-like platforms the library is almost always called libz
         set_target_properties(zlib PROPERTIES

From b74d77a0ddb89b244e80fc61cebe8a032146c950 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Thu, 5 Dec 2024 13:15:49 +0100
Subject: [PATCH 036/128] CMake: Install compatible DLL on MinGW.

---
 CMakeLists.txt | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4aaf62baf..6b160fcf8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -186,6 +186,13 @@ if(ZLIB_INSTALL_LIBRARIES)
             RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
             ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
             LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
+        if(ZLIB_INSTALL_COMPAT_DLL AND MINGW)
+            install(FILES  $<TARGET_FILE:zlibstatic>
+                COMPONENT Development
+                RENAME libz.dll.a
+                DESTINATION "${CMAKE_INSTALL_LIBDIR}")
+        endif(ZLIB_INSTALL_COMPAT_DLL)
+
     endif(ZLIB_BUILD_STATIC)
 
     configure_package_config_file(${zlib_SOURCE_DIR}/zlibConfig.cmake.in

From fd00a948388c9926f6caecdb72bccbfcb0ea29e0 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Thu, 5 Dec 2024 13:17:14 +0100
Subject: [PATCH 037/128] CMake: Disable MinGW and Cygwin tests.

---
 .github/workflows/msys-cygwin.txt | 74 +++++++++++++++++++++++++++++++
 CMakeLists.txt                    |  2 +-
 test/CMakeLists.txt               |  9 ++--
 3 files changed, 81 insertions(+), 4 deletions(-)
 create mode 100644 .github/workflows/msys-cygwin.txt

diff --git a/.github/workflows/msys-cygwin.txt b/.github/workflows/msys-cygwin.txt
new file mode 100644
index 000000000..5ad7a7343
--- /dev/null
+++ b/.github/workflows/msys-cygwin.txt
@@ -0,0 +1,74 @@
+name: mingw/cygwin
+
+on: [push, pull_request]
+
+jobs:
+  MSys:
+    runs-on: windows-latest
+    strategy:
+      fail-fast: false
+      matrix:
+        sys: [mingw32, mingw64, ucrt64, clang64]
+    name: MSys - ${{ matrix.sys }}
+    defaults:
+      run:
+        shell: msys2 {0}
+    steps:
+    - name: Checkout
+      uses: actions/checkout@v4
+      with:
+        fetch-depth: 0
+    - name: Setup MSYS2
+      uses: msys2/setup-msys2@v2
+      with:
+        msystem: ${{ matrix.sys }}
+        update: true
+        install: >-
+          make
+        pacboy: >-
+          toolchain:p
+          cmake:p
+    - name: Configure
+      run: |
+        cmake -G"Unix Makefiles" \
+          -S . \
+          -B build \
+          -DCMAKE_VERBOSE_MAKEFILE=ON \
+          -DCMAKE_BUILD_TYPE=Release
+    - name: Build
+      run: cmake --build build --config Release
+    - name: Run tests
+      run: ctest --output-on-failure --test-dir build -C Release
+
+  cygwin:
+    strategy:
+      fail-fast: false
+    runs-on: windows-latest
+    defaults:
+      run:
+        shell: C:\cygwin\bin\bash.exe --login -o igncr '{0}'
+    name: Cygwin
+    steps:
+    - name: Checkout
+      uses: actions/checkout@v4
+      with:
+        fetch-depth: 0
+    - name: Setup cygwin
+      uses: cygwin/cygwin-install-action@master
+      with:
+        packages: >-
+          cmake
+          cygwin-devel
+          gcc-core
+          gcc-g++
+          ninja
+    - name: Configure
+      run: |
+        cmake /cygdrive/d/a/zlib/zlib \
+          -B build \
+          -DCMAKE_BUILD_TYPE=Release \
+          -G Ninja
+    - name: Build
+      run: cmake --build build --config Release
+    - name: Run tests
+      run: ctest --output-on-failure --test-dir build -C Release
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6b160fcf8..c5ca71362 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -191,7 +191,7 @@ if(ZLIB_INSTALL_LIBRARIES)
                 COMPONENT Development
                 RENAME libz.dll.a
                 DESTINATION "${CMAKE_INSTALL_LIBDIR}")
-        endif(ZLIB_INSTALL_COMPAT_DLL)
+        endif(ZLIB_INSTALL_COMPAT_DLL AND MINGW)
 
     endif(ZLIB_BUILD_STATIC)
 
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 235ae5ef3..4ea87861c 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -61,7 +61,8 @@ set_tests_properties(zlib_test_build_find_package PROPERTIES
     FIXTURES_SETUP fp_build)
 
 set_tests_properties(zlib_test_test_find_package PROPERTIES
-    FIXTURES_REQUIRED fp_build)
+    FIXTURES_REQUIRED fp_build
+    ENVIRONMENT CTEST_OUTPUT_ON_FAILURE=1)
 
 #
 # add_subdirectory_test
@@ -95,7 +96,8 @@ set_tests_properties(zlib_test_build_add_subdirectory PROPERTIES
     FIXTURES_SETUP as_build)
 
 set_tests_properties(zlib_test_test_add_subdirectory PROPERTIES
-    FIXTURES_REQUIRED as_build)
+    FIXTURES_REQUIRED as_build
+    ENVIRONMENT CTEST_OUTPUT_ON_FAILURE=1)
 
 #
 # add_subdirectory_exclude_test
@@ -129,4 +131,5 @@ set_tests_properties(zlib_test_build_add_subdirectory_exclude PROPERTIES
     FIXTURES_SETUP asx_build)
 
 set_tests_properties(zlib_test_test_add_subdirectory_exclude PROPERTIES
-    FIXTURES_REQUIRED asx_build)
+    FIXTURES_REQUIRED asx_build
+    ENVIRONMENT CTEST_OUTPUT_ON_FAILURE=1)

From 155d88378e76b3bf123da4301a5b82aad17d06bc Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Thu, 5 Dec 2024 17:22:17 +0100
Subject: [PATCH 038/128] CMake: Test static builds.

---
 CMakeLists.txt | 57 +++++++++++++++++++++++++++++++++++---------------
 1 file changed, 40 insertions(+), 17 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c5ca71362..e05b92b6b 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)

From 15ba5055a935413c087a935e428eac35066acc29 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Thu, 5 Dec 2024 19:01:48 +0100
Subject: [PATCH 039/128] CMake: Adapt pkgconfig-file to the GnuInstallDirs
 layout.

---
 zlib.pc.cmakein | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/zlib.pc.cmakein b/zlib.pc.cmakein
index a5e642938..6da9e49fd 100644
--- a/zlib.pc.cmakein
+++ b/zlib.pc.cmakein
@@ -1,12 +1,12 @@
 prefix=@CMAKE_INSTALL_PREFIX@
 exec_prefix=@CMAKE_INSTALL_PREFIX@
-libdir=@INSTALL_LIB_DIR@
-sharedlibdir=@INSTALL_LIB_DIR@
-includedir=@INSTALL_INC_DIR@
+libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
+sharedlibdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
+includedir=${exec_prefix}/@CMAKE_INSTALL_INCLUDEDIR@
 
 Name: zlib
 Description: zlib compression library
-Version: @VERSION@
+Version: @zlib_VERSION@
 
 Requires:
 Libs: -L${libdir} -L${sharedlibdir} -lz

From 53c2727aaf0ffbc052a50c80931b40cf5eb8ee65 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Thu, 5 Dec 2024 19:02:29 +0100
Subject: [PATCH 040/128] CMake: Silence deprecation warning on the action
 runners.

---
 CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e05b92b6b..167c04505 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.9)
+cmake_minimum_required(VERSION 3.10)
 
 project(zlib
     LANGUAGES C

From 9e058e844334a6f9289bf6e6650ca46d4a3e2ce9 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Sat, 7 Dec 2024 17:20:40 +0100
Subject: [PATCH 041/128] CMake: Add option for ZLIB_PREFIX.

---
 CMakeLists.txt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 167c04505..7e8e89cd1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,6 +8,10 @@ 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_INSTALL_LIBRARIES "Enable installation of zlib" ON)
+option(ZLIB_PREFIX
+    "prefix for all types and library functions, see zconf.h.in"
+    OFF)
+mark_as_advanced(ZLIB_PREFIX)
 
 if(WIN32)
     option(ZLIB_INSTALL_COMPAT_DLL "Install a copy as zlib1.dll" ON)

From 3d6dc3c3aa73fc5421a7671b32d1dd251fea1edc Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Sat, 7 Dec 2024 17:23:40 +0100
Subject: [PATCH 042/128] CMake: Create zconf.h from zconf.h.in.

Instead of zconf.h.cmakein, which is removed.
---
 CMakeLists.txt  |  76 +++++--
 zconf.h.cmakein | 546 ------------------------------------------------
 2 files changed, 61 insertions(+), 561 deletions(-)
 delete mode 100644 zconf.h.cmakein

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7e8e89cd1..4b80bc79f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -31,6 +31,30 @@ include(CheckCSourceCompiles)
 include(CMakePackageConfigHelpers)
 include(GNUInstallDirs)
 
+if(NOT ZLIB_CONF_WRITTEN)
+    set(Z_PREFIX ${ZLIB_PREFIX})
+    set(CONF_OUT_FILE ${zlib_BINARY_DIR}/zconf.h.cmakein)
+    file(READ ${zlib_SOURCE_DIR}/zconf.h.in ZCONF_CONTENT LIMIT 245)
+    file(WRITE ${CONF_OUT_FILE} ${ZCONF_CONTENT})
+    file(APPEND ${CONF_OUT_FILE} "#cmakedefine01 Z_PREFIX\n")
+    file(APPEND ${CONF_OUT_FILE} "#cmakedefine01 HAVE_STDARG_H\n")
+    file(APPEND ${CONF_OUT_FILE} "#cmakedefine01 HAVE_UNISTD_H\n")
+    file(READ ${zlib_SOURCE_DIR}/zconf.h.in ZCONF_CONTENT OFFSET 244)
+    set(FIRST_ITEM TRUE)
+
+    foreach(item IN LISTS ZCONF_CONTENT)
+        if(FIRST_ITEM)
+            string(APPEND OUT_CONTENT ${item})
+            set(FIRST_ITEM FALSE)
+        else(FIRST_ITEM)
+            string(APPEND OUT_CONTENT "\;" ${item})
+        endif(FIRST_ITEM)
+    endforeach(item IN LISTS ${ZCONF_CONTENT})
+
+    file(APPEND ${CONF_OUT_FILE} ${OUT_CONTENT})
+    set(ZLIB_CONF_WRITTEN TRUE CACHE BOOL "zconf.h.cmakein was created")
+    mark_as_advanced(ZLIB_CONF_WRITTEN)
+endif(NOT ZLIB_CONF_WRITTEN)
 #
 # Check to see if we have large file support
 #
@@ -43,16 +67,31 @@ set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
 #
 check_function_exists(fseeko HAVE_FSEEKO)
 
+#
+# Check for stdarg.h
+#
+check_include_file(stdarg.h HAVE_STDARG_H)
+
 #
 # Check for unistd.h
 #
-check_include_file(unistd.h Z_HAVE_UNISTD_H)
+check_include_file(unistd.h HAVE_UNISTD_H)
+
+#
+# Check visibility attribute is supported
+check_c_source_compiles(
+    "
+        #include <stdlib.h>
+        static void f(void) __attribute__ ((visibility(\"hidden\")));
+        int main(void) {return 0;}
+    "
+    HAVE___ATTR__VIS_HIDDEN)
 
 set(ZLIB_PC ${zlib_BINARY_DIR}/zlib.pc)
 configure_file(${zlib_SOURCE_DIR}/zlib.pc.cmakein
                ${ZLIB_PC} @ONLY)
-configure_file(${zlib_SOURCE_DIR}/zconf.h.cmakein
-               ${zlib_BINARY_DIR}/zconf.h @ONLY)
+configure_file(${zlib_BINARY_DIR}/zconf.h.cmakein
+               ${zlib_BINARY_DIR}/zconf.h)
 include_directories(${zlib_BINARY_DIR} ${zlib_SOURCE_DIR})
 
 #============================================================================
@@ -113,10 +152,12 @@ if(ZLIB_BUILD_SHARED)
         $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
     target_compile_definitions(zlib
         PRIVATE
-            $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>
             $<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
+            $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
             $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
-            $<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>)
+            $<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>
+        PUBLIC
+            $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
     set(INSTALL_VERSION ${zlib_VERSION_MAJOR})
 
     if(NOT CYGWIN)
@@ -149,6 +190,7 @@ if(ZLIB_BUILD_STATIC)
     target_compile_definitions(zlibstatic
         PRIVATE
             $<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
+            $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
             $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
             $<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>
         PUBLIC
@@ -242,23 +284,28 @@ if(ZLIB_BUILD_TESTING)
         add_test(zlib_example zlib_example)
 
         add_executable(minigzip test/minigzip.c)
+        target_compile_definitions(zlib
+            PRIVATE
+                $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
         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_compile_definitions(zlib_example64
+                PRIVATE
+                    LARGEFILE64_SOURCE=1
+                    $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
             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)
+        target_compile_definitions(zlib_static_example
+            PRIVATE
+                $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
         add_test(zlib_static_example zlib_static_example)
 
         add_executable(static_minigzip test/minigzip.c)
@@ -266,13 +313,12 @@ if(ZLIB_BUILD_TESTING)
 
         if(HAVE_OFF64_T)
             add_executable(zlib_static_example64 test/example.c)
-            target_compile_definitions(zlib_static_example64 PRIVATE LARGEFILE64_SOURCE=1)
+            target_compile_definitions(zlib_static_example64
+                PRIVATE
+                    LARGEFILE64_SOURCE=1
+                    $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
             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)
 
diff --git a/zconf.h.cmakein b/zconf.h.cmakein
deleted file mode 100644
index f43a90448..000000000
--- a/zconf.h.cmakein
+++ /dev/null
@@ -1,546 +0,0 @@
-/* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#ifndef ZCONF_H
-#define ZCONF_H
-#cmakedefine Z_PREFIX
-#cmakedefine Z_HAVE_UNISTD_H
-
-/*
- * If you *really* need a unique prefix for all types and library functions,
- * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
- * Even better than compiling with -DZ_PREFIX would be to use configure to set
- * this permanently in zconf.h using "./configure --zprefix".
- */
-#ifdef Z_PREFIX     /* may be set to #if 1 by ./configure */
-#  define Z_PREFIX_SET
-
-/* all linked symbols and init macros */
-#  define _dist_code            z__dist_code
-#  define _length_code          z__length_code
-#  define _tr_align             z__tr_align
-#  define _tr_flush_bits        z__tr_flush_bits
-#  define _tr_flush_block       z__tr_flush_block
-#  define _tr_init              z__tr_init
-#  define _tr_stored_block      z__tr_stored_block
-#  define _tr_tally             z__tr_tally
-#  define adler32               z_adler32
-#  define adler32_combine       z_adler32_combine
-#  define adler32_combine64     z_adler32_combine64
-#  define adler32_z             z_adler32_z
-#  ifndef Z_SOLO
-#    define compress              z_compress
-#    define compress2             z_compress2
-#    define compressBound         z_compressBound
-#  endif
-#  define crc32                 z_crc32
-#  define crc32_combine         z_crc32_combine
-#  define crc32_combine64       z_crc32_combine64
-#  define crc32_combine_gen     z_crc32_combine_gen
-#  define crc32_combine_gen64   z_crc32_combine_gen64
-#  define crc32_combine_op      z_crc32_combine_op
-#  define crc32_z               z_crc32_z
-#  define deflate               z_deflate
-#  define deflateBound          z_deflateBound
-#  define deflateCopy           z_deflateCopy
-#  define deflateEnd            z_deflateEnd
-#  define deflateGetDictionary  z_deflateGetDictionary
-#  define deflateInit           z_deflateInit
-#  define deflateInit2          z_deflateInit2
-#  define deflateInit2_         z_deflateInit2_
-#  define deflateInit_          z_deflateInit_
-#  define deflateParams         z_deflateParams
-#  define deflatePending        z_deflatePending
-#  define deflatePrime          z_deflatePrime
-#  define deflateReset          z_deflateReset
-#  define deflateResetKeep      z_deflateResetKeep
-#  define deflateSetDictionary  z_deflateSetDictionary
-#  define deflateSetHeader      z_deflateSetHeader
-#  define deflateTune           z_deflateTune
-#  define deflateUsed           z_deflateUsed
-#  define deflate_copyright     z_deflate_copyright
-#  define get_crc_table         z_get_crc_table
-#  ifndef Z_SOLO
-#    define gz_error              z_gz_error
-#    define gz_intmax             z_gz_intmax
-#    define gz_strwinerror        z_gz_strwinerror
-#    define gzbuffer              z_gzbuffer
-#    define gzclearerr            z_gzclearerr
-#    define gzclose               z_gzclose
-#    define gzclose_r             z_gzclose_r
-#    define gzclose_w             z_gzclose_w
-#    define gzdirect              z_gzdirect
-#    define gzdopen               z_gzdopen
-#    define gzeof                 z_gzeof
-#    define gzerror               z_gzerror
-#    define gzflush               z_gzflush
-#    define gzfread               z_gzfread
-#    define gzfwrite              z_gzfwrite
-#    define gzgetc                z_gzgetc
-#    define gzgetc_               z_gzgetc_
-#    define gzgets                z_gzgets
-#    define gzoffset              z_gzoffset
-#    define gzoffset64            z_gzoffset64
-#    define gzopen                z_gzopen
-#    define gzopen64              z_gzopen64
-#    ifdef _WIN32
-#      define gzopen_w              z_gzopen_w
-#    endif
-#    define gzprintf              z_gzprintf
-#    define gzputc                z_gzputc
-#    define gzputs                z_gzputs
-#    define gzread                z_gzread
-#    define gzrewind              z_gzrewind
-#    define gzseek                z_gzseek
-#    define gzseek64              z_gzseek64
-#    define gzsetparams           z_gzsetparams
-#    define gztell                z_gztell
-#    define gztell64              z_gztell64
-#    define gzungetc              z_gzungetc
-#    define gzvprintf             z_gzvprintf
-#    define gzwrite               z_gzwrite
-#  endif
-#  define inflate               z_inflate
-#  define inflateBack           z_inflateBack
-#  define inflateBackEnd        z_inflateBackEnd
-#  define inflateBackInit       z_inflateBackInit
-#  define inflateBackInit_      z_inflateBackInit_
-#  define inflateCodesUsed      z_inflateCodesUsed
-#  define inflateCopy           z_inflateCopy
-#  define inflateEnd            z_inflateEnd
-#  define inflateGetDictionary  z_inflateGetDictionary
-#  define inflateGetHeader      z_inflateGetHeader
-#  define inflateInit           z_inflateInit
-#  define inflateInit2          z_inflateInit2
-#  define inflateInit2_         z_inflateInit2_
-#  define inflateInit_          z_inflateInit_
-#  define inflateMark           z_inflateMark
-#  define inflatePrime          z_inflatePrime
-#  define inflateReset          z_inflateReset
-#  define inflateReset2         z_inflateReset2
-#  define inflateResetKeep      z_inflateResetKeep
-#  define inflateSetDictionary  z_inflateSetDictionary
-#  define inflateSync           z_inflateSync
-#  define inflateSyncPoint      z_inflateSyncPoint
-#  define inflateUndermine      z_inflateUndermine
-#  define inflateValidate       z_inflateValidate
-#  define inflate_copyright     z_inflate_copyright
-#  define inflate_fast          z_inflate_fast
-#  define inflate_table         z_inflate_table
-#  ifndef Z_SOLO
-#    define uncompress            z_uncompress
-#    define uncompress2           z_uncompress2
-#  endif
-#  define zError                z_zError
-#  ifndef Z_SOLO
-#    define zcalloc               z_zcalloc
-#    define zcfree                z_zcfree
-#  endif
-#  define zlibCompileFlags      z_zlibCompileFlags
-#  define zlibVersion           z_zlibVersion
-
-/* all zlib typedefs in zlib.h and zconf.h */
-#  define Byte                  z_Byte
-#  define Bytef                 z_Bytef
-#  define alloc_func            z_alloc_func
-#  define charf                 z_charf
-#  define free_func             z_free_func
-#  ifndef Z_SOLO
-#    define gzFile                z_gzFile
-#  endif
-#  define gz_header             z_gz_header
-#  define gz_headerp            z_gz_headerp
-#  define in_func               z_in_func
-#  define intf                  z_intf
-#  define out_func              z_out_func
-#  define uInt                  z_uInt
-#  define uIntf                 z_uIntf
-#  define uLong                 z_uLong
-#  define uLongf                z_uLongf
-#  define voidp                 z_voidp
-#  define voidpc                z_voidpc
-#  define voidpf                z_voidpf
-
-/* all zlib structs in zlib.h and zconf.h */
-#  define gz_header_s           z_gz_header_s
-#  define internal_state        z_internal_state
-
-#endif
-
-#if defined(__MSDOS__) && !defined(MSDOS)
-#  define MSDOS
-#endif
-#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
-#  define OS2
-#endif
-#if defined(_WINDOWS) && !defined(WINDOWS)
-#  define WINDOWS
-#endif
-#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
-#  ifndef WIN32
-#    define WIN32
-#  endif
-#endif
-#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
-#  if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
-#    ifndef SYS16BIT
-#      define SYS16BIT
-#    endif
-#  endif
-#endif
-
-/*
- * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
- * than 64k bytes at a time (needed on systems with 16-bit int).
- */
-#ifdef SYS16BIT
-#  define MAXSEG_64K
-#endif
-#ifdef MSDOS
-#  define UNALIGNED_OK
-#endif
-
-#ifdef __STDC_VERSION__
-#  ifndef STDC
-#    define STDC
-#  endif
-#  if __STDC_VERSION__ >= 199901L
-#    ifndef STDC99
-#      define STDC99
-#    endif
-#  endif
-#endif
-#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
-#  define STDC
-#endif
-#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
-#  define STDC
-#endif
-#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
-#  define STDC
-#endif
-#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
-#  define STDC
-#endif
-
-#if defined(__OS400__) && !defined(STDC)    /* iSeries (formerly AS/400). */
-#  define STDC
-#endif
-
-#ifndef STDC
-#  ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
-#    define const       /* note: need a more gentle solution here */
-#  endif
-#endif
-
-#ifndef z_const
-#  ifdef ZLIB_CONST
-#    define z_const const
-#  else
-#    define z_const
-#  endif
-#endif
-
-#ifdef Z_SOLO
-#  ifdef _WIN64
-     typedef unsigned long long z_size_t;
-#  else
-     typedef unsigned long z_size_t;
-#  endif
-#else
-#  define z_longlong long long
-#  if defined(NO_SIZE_T)
-     typedef unsigned NO_SIZE_T z_size_t;
-#  elif defined(STDC)
-#    include <stddef.h>
-     typedef size_t z_size_t;
-#  else
-     typedef unsigned long z_size_t;
-#  endif
-#  undef z_longlong
-#endif
-
-/* Maximum value for memLevel in deflateInit2 */
-#ifndef MAX_MEM_LEVEL
-#  ifdef MAXSEG_64K
-#    define MAX_MEM_LEVEL 8
-#  else
-#    define MAX_MEM_LEVEL 9
-#  endif
-#endif
-
-/* Maximum value for windowBits in deflateInit2 and inflateInit2.
- * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
- * created by gzip. (Files created by minigzip can still be extracted by
- * gzip.)
- */
-#ifndef MAX_WBITS
-#  define MAX_WBITS   15 /* 32K LZ77 window */
-#endif
-
-/* The memory requirements for deflate are (in bytes):
-            (1 << (windowBits+2)) +  (1 << (memLevel+9))
- that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)
- plus a few kilobytes for small objects. For example, if you want to reduce
- the default memory requirements from 256K to 128K, compile with
-     make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
- Of course this will generally degrade compression (there's no free lunch).
-
-   The memory requirements for inflate are (in bytes) 1 << windowBits
- that is, 32K for windowBits=15 (default value) plus about 7 kilobytes
- for small objects.
-*/
-
-                        /* Type declarations */
-
-#ifndef OF /* function prototypes */
-#  ifdef STDC
-#    define OF(args)  args
-#  else
-#    define OF(args)  ()
-#  endif
-#endif
-
-/* The following definitions for FAR are needed only for MSDOS mixed
- * model programming (small or medium model with some far allocations).
- * This was tested only with MSC; for other MSDOS compilers you may have
- * to define NO_MEMCPY in zutil.h.  If you don't need the mixed model,
- * just define FAR to be empty.
- */
-#ifdef SYS16BIT
-#  if defined(M_I86SM) || defined(M_I86MM)
-     /* MSC small or medium model */
-#    define SMALL_MEDIUM
-#    ifdef _MSC_VER
-#      define FAR _far
-#    else
-#      define FAR far
-#    endif
-#  endif
-#  if (defined(__SMALL__) || defined(__MEDIUM__))
-     /* Turbo C small or medium model */
-#    define SMALL_MEDIUM
-#    ifdef __BORLANDC__
-#      define FAR _far
-#    else
-#      define FAR far
-#    endif
-#  endif
-#endif
-
-#if defined(WINDOWS) || defined(WIN32)
-   /* If building or using zlib as a DLL, define ZLIB_DLL.
-    * This is not mandatory, but it offers a little performance increase.
-    */
-#  ifdef ZLIB_DLL
-#    if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
-#      ifdef ZLIB_INTERNAL
-#        define ZEXTERN extern __declspec(dllexport)
-#      else
-#        define ZEXTERN extern __declspec(dllimport)
-#      endif
-#    endif
-#  endif  /* ZLIB_DLL */
-   /* If building or using zlib with the WINAPI/WINAPIV calling convention,
-    * define ZLIB_WINAPI.
-    * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
-    */
-#  ifdef ZLIB_WINAPI
-#    ifdef FAR
-#      undef FAR
-#    endif
-#    ifndef WIN32_LEAN_AND_MEAN
-#      define WIN32_LEAN_AND_MEAN
-#    endif
-#    include <windows.h>
-     /* No need for _export, use ZLIB.DEF instead. */
-     /* For complete Windows compatibility, use WINAPI, not __stdcall. */
-#    define ZEXPORT WINAPI
-#    ifdef WIN32
-#      define ZEXPORTVA WINAPIV
-#    else
-#      define ZEXPORTVA FAR CDECL
-#    endif
-#  endif
-#endif
-
-#if defined (__BEOS__)
-#  ifdef ZLIB_DLL
-#    ifdef ZLIB_INTERNAL
-#      define ZEXPORT   __declspec(dllexport)
-#      define ZEXPORTVA __declspec(dllexport)
-#    else
-#      define ZEXPORT   __declspec(dllimport)
-#      define ZEXPORTVA __declspec(dllimport)
-#    endif
-#  endif
-#endif
-
-#ifndef ZEXTERN
-#  define ZEXTERN extern
-#endif
-#ifndef ZEXPORT
-#  define ZEXPORT
-#endif
-#ifndef ZEXPORTVA
-#  define ZEXPORTVA
-#endif
-
-#ifndef FAR
-#  define FAR
-#endif
-
-#if !defined(__MACTYPES__)
-typedef unsigned char  Byte;  /* 8 bits */
-#endif
-typedef unsigned int   uInt;  /* 16 bits or more */
-typedef unsigned long  uLong; /* 32 bits or more */
-
-#ifdef SMALL_MEDIUM
-   /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
-#  define Bytef Byte FAR
-#else
-   typedef Byte  FAR Bytef;
-#endif
-typedef char  FAR charf;
-typedef int   FAR intf;
-typedef uInt  FAR uIntf;
-typedef uLong FAR uLongf;
-
-#ifdef STDC
-   typedef void const *voidpc;
-   typedef void FAR   *voidpf;
-   typedef void       *voidp;
-#else
-   typedef Byte const *voidpc;
-   typedef Byte FAR   *voidpf;
-   typedef Byte       *voidp;
-#endif
-
-#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
-#  include <limits.h>
-#  if (UINT_MAX == 0xffffffffUL)
-#    define Z_U4 unsigned
-#  elif (ULONG_MAX == 0xffffffffUL)
-#    define Z_U4 unsigned long
-#  elif (USHRT_MAX == 0xffffffffUL)
-#    define Z_U4 unsigned short
-#  endif
-#endif
-
-#ifdef Z_U4
-   typedef Z_U4 z_crc_t;
-#else
-   typedef unsigned long z_crc_t;
-#endif
-
-#ifdef HAVE_UNISTD_H    /* may be set to #if 1 by ./configure */
-#  define Z_HAVE_UNISTD_H
-#endif
-
-#ifdef HAVE_STDARG_H    /* may be set to #if 1 by ./configure */
-#  define Z_HAVE_STDARG_H
-#endif
-
-#ifdef STDC
-#  ifndef Z_SOLO
-#    include <sys/types.h>      /* for off_t */
-#  endif
-#endif
-
-#if defined(STDC) || defined(Z_HAVE_STDARG_H)
-#  ifndef Z_SOLO
-#    include <stdarg.h>         /* for va_list */
-#  endif
-#endif
-
-#ifdef _WIN32
-#  ifndef Z_SOLO
-#    include <stddef.h>         /* for wchar_t */
-#  endif
-#endif
-
-/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
- * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
- * though the former does not conform to the LFS document), but considering
- * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
- * equivalently requesting no 64-bit operations
- */
-#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
-#  undef _LARGEFILE64_SOURCE
-#endif
-
-#ifndef Z_HAVE_UNISTD_H
-#  if defined(__WATCOMC__) || defined(__GO32__) || \
-      (defined(_LARGEFILE64_SOURCE) && !defined(_WIN32))
-#    define Z_HAVE_UNISTD_H
-#  endif
-#endif
-#ifndef Z_SOLO
-#  if defined(Z_HAVE_UNISTD_H)
-#    include <unistd.h>         /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
-#    ifdef VMS
-#      include <unixio.h>       /* for off_t */
-#    endif
-#    ifndef z_off_t
-#      define z_off_t off_t
-#    endif
-#  endif
-#endif
-
-#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
-#  define Z_LFS64
-#endif
-
-#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
-#  define Z_LARGE64
-#endif
-
-#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
-#  define Z_WANT64
-#endif
-
-#if !defined(SEEK_SET) && !defined(Z_SOLO)
-#  define SEEK_SET        0       /* Seek from beginning of file.  */
-#  define SEEK_CUR        1       /* Seek from current position.  */
-#  define SEEK_END        2       /* Set file pointer to EOF plus "offset" */
-#endif
-
-#ifndef z_off_t
-#  define z_off_t long long
-#endif
-
-#if !defined(_WIN32) && defined(Z_LARGE64)
-#  define z_off64_t off64_t
-#elif defined(__MINGW32__)
-#  define z_off64_t long long
-#elif defined(_WIN32) && !defined(__GNUC__)
-#  define z_off64_t __int64
-#elif defined(__GO32__)
-#  define z_off64_t offset_t
-#else
-#  define z_off64_t z_off_t
-#endif
-
-/* MVS linker does not support external names larger than 8 bytes */
-#if defined(__MVS__)
-  #pragma map(deflateInit_,"DEIN")
-  #pragma map(deflateInit2_,"DEIN2")
-  #pragma map(deflateEnd,"DEEND")
-  #pragma map(deflateBound,"DEBND")
-  #pragma map(inflateInit_,"ININ")
-  #pragma map(inflateInit2_,"ININ2")
-  #pragma map(inflateEnd,"INEND")
-  #pragma map(inflateSync,"INSY")
-  #pragma map(inflateSetDictionary,"INSEDI")
-  #pragma map(compressBound,"CMBND")
-  #pragma map(inflate_table,"INTABL")
-  #pragma map(inflate_fast,"INFA")
-  #pragma map(inflate_copyright,"INCOPY")
-#endif
-
-#endif /* ZCONF_H */

From b5c01971c210544286323a5bf7eefb3095ed4e01 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Sat, 7 Dec 2024 17:26:12 +0100
Subject: [PATCH 043/128] CMake: Remove zconf.h.

zconf.h is always created by cmake and configure.
---
 CMakeLists.txt |   6 +-
 zconf.h        | 544 -------------------------------------------------
 2 files changed, 3 insertions(+), 547 deletions(-)
 delete mode 100644 zconf.h

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4b80bc79f..ef5f46a91 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -36,9 +36,9 @@ if(NOT ZLIB_CONF_WRITTEN)
     set(CONF_OUT_FILE ${zlib_BINARY_DIR}/zconf.h.cmakein)
     file(READ ${zlib_SOURCE_DIR}/zconf.h.in ZCONF_CONTENT LIMIT 245)
     file(WRITE ${CONF_OUT_FILE} ${ZCONF_CONTENT})
-    file(APPEND ${CONF_OUT_FILE} "#cmakedefine01 Z_PREFIX\n")
-    file(APPEND ${CONF_OUT_FILE} "#cmakedefine01 HAVE_STDARG_H\n")
-    file(APPEND ${CONF_OUT_FILE} "#cmakedefine01 HAVE_UNISTD_H\n")
+    file(APPEND ${CONF_OUT_FILE} "#cmakedefine Z_PREFIX 1\n")
+    file(APPEND ${CONF_OUT_FILE} "#cmakedefine HAVE_STDARG_H 1\n")
+    file(APPEND ${CONF_OUT_FILE} "#cmakedefine HAVE_UNISTD_H 1\n")
     file(READ ${zlib_SOURCE_DIR}/zconf.h.in ZCONF_CONTENT OFFSET 244)
     set(FIRST_ITEM TRUE)
 
diff --git a/zconf.h b/zconf.h
deleted file mode 100644
index d6c159a1e..000000000
--- a/zconf.h
+++ /dev/null
@@ -1,544 +0,0 @@
-/* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#ifndef ZCONF_H
-#define ZCONF_H
-
-/*
- * If you *really* need a unique prefix for all types and library functions,
- * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
- * Even better than compiling with -DZ_PREFIX would be to use configure to set
- * this permanently in zconf.h using "./configure --zprefix".
- */
-#ifdef Z_PREFIX     /* may be set to #if 1 by ./configure */
-#  define Z_PREFIX_SET
-
-/* all linked symbols and init macros */
-#  define _dist_code            z__dist_code
-#  define _length_code          z__length_code
-#  define _tr_align             z__tr_align
-#  define _tr_flush_bits        z__tr_flush_bits
-#  define _tr_flush_block       z__tr_flush_block
-#  define _tr_init              z__tr_init
-#  define _tr_stored_block      z__tr_stored_block
-#  define _tr_tally             z__tr_tally
-#  define adler32               z_adler32
-#  define adler32_combine       z_adler32_combine
-#  define adler32_combine64     z_adler32_combine64
-#  define adler32_z             z_adler32_z
-#  ifndef Z_SOLO
-#    define compress              z_compress
-#    define compress2             z_compress2
-#    define compressBound         z_compressBound
-#  endif
-#  define crc32                 z_crc32
-#  define crc32_combine         z_crc32_combine
-#  define crc32_combine64       z_crc32_combine64
-#  define crc32_combine_gen     z_crc32_combine_gen
-#  define crc32_combine_gen64   z_crc32_combine_gen64
-#  define crc32_combine_op      z_crc32_combine_op
-#  define crc32_z               z_crc32_z
-#  define deflate               z_deflate
-#  define deflateBound          z_deflateBound
-#  define deflateCopy           z_deflateCopy
-#  define deflateEnd            z_deflateEnd
-#  define deflateGetDictionary  z_deflateGetDictionary
-#  define deflateInit           z_deflateInit
-#  define deflateInit2          z_deflateInit2
-#  define deflateInit2_         z_deflateInit2_
-#  define deflateInit_          z_deflateInit_
-#  define deflateParams         z_deflateParams
-#  define deflatePending        z_deflatePending
-#  define deflatePrime          z_deflatePrime
-#  define deflateReset          z_deflateReset
-#  define deflateResetKeep      z_deflateResetKeep
-#  define deflateSetDictionary  z_deflateSetDictionary
-#  define deflateSetHeader      z_deflateSetHeader
-#  define deflateTune           z_deflateTune
-#  define deflateUsed           z_deflateUsed
-#  define deflate_copyright     z_deflate_copyright
-#  define get_crc_table         z_get_crc_table
-#  ifndef Z_SOLO
-#    define gz_error              z_gz_error
-#    define gz_intmax             z_gz_intmax
-#    define gz_strwinerror        z_gz_strwinerror
-#    define gzbuffer              z_gzbuffer
-#    define gzclearerr            z_gzclearerr
-#    define gzclose               z_gzclose
-#    define gzclose_r             z_gzclose_r
-#    define gzclose_w             z_gzclose_w
-#    define gzdirect              z_gzdirect
-#    define gzdopen               z_gzdopen
-#    define gzeof                 z_gzeof
-#    define gzerror               z_gzerror
-#    define gzflush               z_gzflush
-#    define gzfread               z_gzfread
-#    define gzfwrite              z_gzfwrite
-#    define gzgetc                z_gzgetc
-#    define gzgetc_               z_gzgetc_
-#    define gzgets                z_gzgets
-#    define gzoffset              z_gzoffset
-#    define gzoffset64            z_gzoffset64
-#    define gzopen                z_gzopen
-#    define gzopen64              z_gzopen64
-#    ifdef _WIN32
-#      define gzopen_w              z_gzopen_w
-#    endif
-#    define gzprintf              z_gzprintf
-#    define gzputc                z_gzputc
-#    define gzputs                z_gzputs
-#    define gzread                z_gzread
-#    define gzrewind              z_gzrewind
-#    define gzseek                z_gzseek
-#    define gzseek64              z_gzseek64
-#    define gzsetparams           z_gzsetparams
-#    define gztell                z_gztell
-#    define gztell64              z_gztell64
-#    define gzungetc              z_gzungetc
-#    define gzvprintf             z_gzvprintf
-#    define gzwrite               z_gzwrite
-#  endif
-#  define inflate               z_inflate
-#  define inflateBack           z_inflateBack
-#  define inflateBackEnd        z_inflateBackEnd
-#  define inflateBackInit       z_inflateBackInit
-#  define inflateBackInit_      z_inflateBackInit_
-#  define inflateCodesUsed      z_inflateCodesUsed
-#  define inflateCopy           z_inflateCopy
-#  define inflateEnd            z_inflateEnd
-#  define inflateGetDictionary  z_inflateGetDictionary
-#  define inflateGetHeader      z_inflateGetHeader
-#  define inflateInit           z_inflateInit
-#  define inflateInit2          z_inflateInit2
-#  define inflateInit2_         z_inflateInit2_
-#  define inflateInit_          z_inflateInit_
-#  define inflateMark           z_inflateMark
-#  define inflatePrime          z_inflatePrime
-#  define inflateReset          z_inflateReset
-#  define inflateReset2         z_inflateReset2
-#  define inflateResetKeep      z_inflateResetKeep
-#  define inflateSetDictionary  z_inflateSetDictionary
-#  define inflateSync           z_inflateSync
-#  define inflateSyncPoint      z_inflateSyncPoint
-#  define inflateUndermine      z_inflateUndermine
-#  define inflateValidate       z_inflateValidate
-#  define inflate_copyright     z_inflate_copyright
-#  define inflate_fast          z_inflate_fast
-#  define inflate_table         z_inflate_table
-#  ifndef Z_SOLO
-#    define uncompress            z_uncompress
-#    define uncompress2           z_uncompress2
-#  endif
-#  define zError                z_zError
-#  ifndef Z_SOLO
-#    define zcalloc               z_zcalloc
-#    define zcfree                z_zcfree
-#  endif
-#  define zlibCompileFlags      z_zlibCompileFlags
-#  define zlibVersion           z_zlibVersion
-
-/* all zlib typedefs in zlib.h and zconf.h */
-#  define Byte                  z_Byte
-#  define Bytef                 z_Bytef
-#  define alloc_func            z_alloc_func
-#  define charf                 z_charf
-#  define free_func             z_free_func
-#  ifndef Z_SOLO
-#    define gzFile                z_gzFile
-#  endif
-#  define gz_header             z_gz_header
-#  define gz_headerp            z_gz_headerp
-#  define in_func               z_in_func
-#  define intf                  z_intf
-#  define out_func              z_out_func
-#  define uInt                  z_uInt
-#  define uIntf                 z_uIntf
-#  define uLong                 z_uLong
-#  define uLongf                z_uLongf
-#  define voidp                 z_voidp
-#  define voidpc                z_voidpc
-#  define voidpf                z_voidpf
-
-/* all zlib structs in zlib.h and zconf.h */
-#  define gz_header_s           z_gz_header_s
-#  define internal_state        z_internal_state
-
-#endif
-
-#if defined(__MSDOS__) && !defined(MSDOS)
-#  define MSDOS
-#endif
-#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
-#  define OS2
-#endif
-#if defined(_WINDOWS) && !defined(WINDOWS)
-#  define WINDOWS
-#endif
-#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
-#  ifndef WIN32
-#    define WIN32
-#  endif
-#endif
-#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
-#  if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
-#    ifndef SYS16BIT
-#      define SYS16BIT
-#    endif
-#  endif
-#endif
-
-/*
- * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
- * than 64k bytes at a time (needed on systems with 16-bit int).
- */
-#ifdef SYS16BIT
-#  define MAXSEG_64K
-#endif
-#ifdef MSDOS
-#  define UNALIGNED_OK
-#endif
-
-#ifdef __STDC_VERSION__
-#  ifndef STDC
-#    define STDC
-#  endif
-#  if __STDC_VERSION__ >= 199901L
-#    ifndef STDC99
-#      define STDC99
-#    endif
-#  endif
-#endif
-#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
-#  define STDC
-#endif
-#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
-#  define STDC
-#endif
-#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
-#  define STDC
-#endif
-#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
-#  define STDC
-#endif
-
-#if defined(__OS400__) && !defined(STDC)    /* iSeries (formerly AS/400). */
-#  define STDC
-#endif
-
-#ifndef STDC
-#  ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
-#    define const       /* note: need a more gentle solution here */
-#  endif
-#endif
-
-#ifndef z_const
-#  ifdef ZLIB_CONST
-#    define z_const const
-#  else
-#    define z_const
-#  endif
-#endif
-
-#ifdef Z_SOLO
-#  ifdef _WIN64
-     typedef unsigned long long z_size_t;
-#  else
-     typedef unsigned long z_size_t;
-#  endif
-#else
-#  define z_longlong long long
-#  if defined(NO_SIZE_T)
-     typedef unsigned NO_SIZE_T z_size_t;
-#  elif defined(STDC)
-#    include <stddef.h>
-     typedef size_t z_size_t;
-#  else
-     typedef unsigned long z_size_t;
-#  endif
-#  undef z_longlong
-#endif
-
-/* Maximum value for memLevel in deflateInit2 */
-#ifndef MAX_MEM_LEVEL
-#  ifdef MAXSEG_64K
-#    define MAX_MEM_LEVEL 8
-#  else
-#    define MAX_MEM_LEVEL 9
-#  endif
-#endif
-
-/* Maximum value for windowBits in deflateInit2 and inflateInit2.
- * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
- * created by gzip. (Files created by minigzip can still be extracted by
- * gzip.)
- */
-#ifndef MAX_WBITS
-#  define MAX_WBITS   15 /* 32K LZ77 window */
-#endif
-
-/* The memory requirements for deflate are (in bytes):
-            (1 << (windowBits+2)) +  (1 << (memLevel+9))
- that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)
- plus a few kilobytes for small objects. For example, if you want to reduce
- the default memory requirements from 256K to 128K, compile with
-     make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
- Of course this will generally degrade compression (there's no free lunch).
-
-   The memory requirements for inflate are (in bytes) 1 << windowBits
- that is, 32K for windowBits=15 (default value) plus about 7 kilobytes
- for small objects.
-*/
-
-                        /* Type declarations */
-
-#ifndef OF /* function prototypes */
-#  ifdef STDC
-#    define OF(args)  args
-#  else
-#    define OF(args)  ()
-#  endif
-#endif
-
-/* The following definitions for FAR are needed only for MSDOS mixed
- * model programming (small or medium model with some far allocations).
- * This was tested only with MSC; for other MSDOS compilers you may have
- * to define NO_MEMCPY in zutil.h.  If you don't need the mixed model,
- * just define FAR to be empty.
- */
-#ifdef SYS16BIT
-#  if defined(M_I86SM) || defined(M_I86MM)
-     /* MSC small or medium model */
-#    define SMALL_MEDIUM
-#    ifdef _MSC_VER
-#      define FAR _far
-#    else
-#      define FAR far
-#    endif
-#  endif
-#  if (defined(__SMALL__) || defined(__MEDIUM__))
-     /* Turbo C small or medium model */
-#    define SMALL_MEDIUM
-#    ifdef __BORLANDC__
-#      define FAR _far
-#    else
-#      define FAR far
-#    endif
-#  endif
-#endif
-
-#if defined(WINDOWS) || defined(WIN32)
-   /* If building or using zlib as a DLL, define ZLIB_DLL.
-    * This is not mandatory, but it offers a little performance increase.
-    */
-#  ifdef ZLIB_DLL
-#    if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
-#      ifdef ZLIB_INTERNAL
-#        define ZEXTERN extern __declspec(dllexport)
-#      else
-#        define ZEXTERN extern __declspec(dllimport)
-#      endif
-#    endif
-#  endif  /* ZLIB_DLL */
-   /* If building or using zlib with the WINAPI/WINAPIV calling convention,
-    * define ZLIB_WINAPI.
-    * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
-    */
-#  ifdef ZLIB_WINAPI
-#    ifdef FAR
-#      undef FAR
-#    endif
-#    ifndef WIN32_LEAN_AND_MEAN
-#      define WIN32_LEAN_AND_MEAN
-#    endif
-#    include <windows.h>
-     /* No need for _export, use ZLIB.DEF instead. */
-     /* For complete Windows compatibility, use WINAPI, not __stdcall. */
-#    define ZEXPORT WINAPI
-#    ifdef WIN32
-#      define ZEXPORTVA WINAPIV
-#    else
-#      define ZEXPORTVA FAR CDECL
-#    endif
-#  endif
-#endif
-
-#if defined (__BEOS__)
-#  ifdef ZLIB_DLL
-#    ifdef ZLIB_INTERNAL
-#      define ZEXPORT   __declspec(dllexport)
-#      define ZEXPORTVA __declspec(dllexport)
-#    else
-#      define ZEXPORT   __declspec(dllimport)
-#      define ZEXPORTVA __declspec(dllimport)
-#    endif
-#  endif
-#endif
-
-#ifndef ZEXTERN
-#  define ZEXTERN extern
-#endif
-#ifndef ZEXPORT
-#  define ZEXPORT
-#endif
-#ifndef ZEXPORTVA
-#  define ZEXPORTVA
-#endif
-
-#ifndef FAR
-#  define FAR
-#endif
-
-#if !defined(__MACTYPES__)
-typedef unsigned char  Byte;  /* 8 bits */
-#endif
-typedef unsigned int   uInt;  /* 16 bits or more */
-typedef unsigned long  uLong; /* 32 bits or more */
-
-#ifdef SMALL_MEDIUM
-   /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
-#  define Bytef Byte FAR
-#else
-   typedef Byte  FAR Bytef;
-#endif
-typedef char  FAR charf;
-typedef int   FAR intf;
-typedef uInt  FAR uIntf;
-typedef uLong FAR uLongf;
-
-#ifdef STDC
-   typedef void const *voidpc;
-   typedef void FAR   *voidpf;
-   typedef void       *voidp;
-#else
-   typedef Byte const *voidpc;
-   typedef Byte FAR   *voidpf;
-   typedef Byte       *voidp;
-#endif
-
-#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
-#  include <limits.h>
-#  if (UINT_MAX == 0xffffffffUL)
-#    define Z_U4 unsigned
-#  elif (ULONG_MAX == 0xffffffffUL)
-#    define Z_U4 unsigned long
-#  elif (USHRT_MAX == 0xffffffffUL)
-#    define Z_U4 unsigned short
-#  endif
-#endif
-
-#ifdef Z_U4
-   typedef Z_U4 z_crc_t;
-#else
-   typedef unsigned long z_crc_t;
-#endif
-
-#ifdef HAVE_UNISTD_H    /* may be set to #if 1 by ./configure */
-#  define Z_HAVE_UNISTD_H
-#endif
-
-#ifdef HAVE_STDARG_H    /* may be set to #if 1 by ./configure */
-#  define Z_HAVE_STDARG_H
-#endif
-
-#ifdef STDC
-#  ifndef Z_SOLO
-#    include <sys/types.h>      /* for off_t */
-#  endif
-#endif
-
-#if defined(STDC) || defined(Z_HAVE_STDARG_H)
-#  ifndef Z_SOLO
-#    include <stdarg.h>         /* for va_list */
-#  endif
-#endif
-
-#ifdef _WIN32
-#  ifndef Z_SOLO
-#    include <stddef.h>         /* for wchar_t */
-#  endif
-#endif
-
-/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
- * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
- * though the former does not conform to the LFS document), but considering
- * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
- * equivalently requesting no 64-bit operations
- */
-#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
-#  undef _LARGEFILE64_SOURCE
-#endif
-
-#ifndef Z_HAVE_UNISTD_H
-#  if defined(__WATCOMC__) || defined(__GO32__) || \
-      (defined(_LARGEFILE64_SOURCE) && !defined(_WIN32))
-#    define Z_HAVE_UNISTD_H
-#  endif
-#endif
-#ifndef Z_SOLO
-#  if defined(Z_HAVE_UNISTD_H)
-#    include <unistd.h>         /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
-#    ifdef VMS
-#      include <unixio.h>       /* for off_t */
-#    endif
-#    ifndef z_off_t
-#      define z_off_t off_t
-#    endif
-#  endif
-#endif
-
-#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
-#  define Z_LFS64
-#endif
-
-#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
-#  define Z_LARGE64
-#endif
-
-#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
-#  define Z_WANT64
-#endif
-
-#if !defined(SEEK_SET) && !defined(Z_SOLO)
-#  define SEEK_SET        0       /* Seek from beginning of file.  */
-#  define SEEK_CUR        1       /* Seek from current position.  */
-#  define SEEK_END        2       /* Set file pointer to EOF plus "offset" */
-#endif
-
-#ifndef z_off_t
-#  define z_off_t long long
-#endif
-
-#if !defined(_WIN32) && defined(Z_LARGE64)
-#  define z_off64_t off64_t
-#elif defined(__MINGW32__)
-#  define z_off64_t long long
-#elif defined(_WIN32) && !defined(__GNUC__)
-#  define z_off64_t __int64
-#elif defined(__GO32__)
-#  define z_off64_t offset_t
-#else
-#  define z_off64_t z_off_t
-#endif
-
-/* MVS linker does not support external names larger than 8 bytes */
-#if defined(__MVS__)
-  #pragma map(deflateInit_,"DEIN")
-  #pragma map(deflateInit2_,"DEIN2")
-  #pragma map(deflateEnd,"DEEND")
-  #pragma map(deflateBound,"DEBND")
-  #pragma map(inflateInit_,"ININ")
-  #pragma map(inflateInit2_,"ININ2")
-  #pragma map(inflateEnd,"INEND")
-  #pragma map(inflateSync,"INSY")
-  #pragma map(inflateSetDictionary,"INSEDI")
-  #pragma map(compressBound,"CMBND")
-  #pragma map(inflate_table,"INTABL")
-  #pragma map(inflate_fast,"INFA")
-  #pragma map(inflate_copyright,"INCOPY")
-#endif
-
-#endif /* ZCONF_H */

From 79d96ebdb7f75ea5ac73adca12d3f125981a1f5c Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 11 Dec 2024 09:07:56 +0100
Subject: [PATCH 044/128] CMake: Clear variable with unset.

---
 CMakeLists.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ef5f46a91..4fd462a18 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -55,12 +55,13 @@ if(NOT ZLIB_CONF_WRITTEN)
     set(ZLIB_CONF_WRITTEN TRUE CACHE BOOL "zconf.h.cmakein was created")
     mark_as_advanced(ZLIB_CONF_WRITTEN)
 endif(NOT ZLIB_CONF_WRITTEN)
+
 #
 # Check to see if we have large file support
 #
 set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
 check_type_size(off64_t OFF64_T)
-set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
+unset(CMAKE_REQUIRED_DEFINITIONS) # clear variable
 
 #
 # Check for fseeko
@@ -87,6 +88,7 @@ check_c_source_compiles(
     "
     HAVE___ATTR__VIS_HIDDEN)
 
+unset(CMAKE_COMPILE_FLAGS)
 set(ZLIB_PC ${zlib_BINARY_DIR}/zlib.pc)
 configure_file(${zlib_SOURCE_DIR}/zlib.pc.cmakein
                ${ZLIB_PC} @ONLY)

From a7c6dbf821988d356b79c71db8d658c43b0d6bbc Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 11 Dec 2024 09:08:47 +0100
Subject: [PATCH 045/128] CMake: Detect visibility attribute in MSVC.

---
 CMakeLists.txt | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4fd462a18..0974c5589 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -80,6 +80,13 @@ check_include_file(unistd.h HAVE_UNISTD_H)
 
 #
 # 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 <stdlib.h>

From 82665659ad0fffd3a14631556141b68b9303aaa7 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 11 Dec 2024 09:09:07 +0100
Subject: [PATCH 046/128] CMake: Remove leading underscore from
 _LARGEFILE64_SOURCE.

---
 CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0974c5589..b0d2bfbf1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -203,7 +203,7 @@ if(ZLIB_BUILD_STATIC)
             $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
             $<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>
         PUBLIC
-            $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
+            $<$<BOOL:${HAVE_OFF64_T}>:LARGEFILE64_SOURCE=1>)
     set_target_properties(zlibstatic PROPERTIES
         EXPORT_NAME ZLIBSTATIC
         OUTPUT_NAME z${zlib_static_suffix})

From cff14d5dc3963afa2328767e932edc4466a32fb1 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 11 Dec 2024 09:09:45 +0100
Subject: [PATCH 047/128] CMake: Use the full version number.

---
 CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b0d2bfbf1..66aa96eaf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -167,7 +167,7 @@ if(ZLIB_BUILD_SHARED)
             $<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>
         PUBLIC
             $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
-    set(INSTALL_VERSION ${zlib_VERSION_MAJOR})
+    set(INSTALL_VERSION ${zlib_VERSION})
 
     if(NOT CYGWIN)
         set_target_properties(zlib PROPERTIES

From adb40de349d1cda5a24806aa46b1c72251321f35 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 11 Dec 2024 09:10:44 +0100
Subject: [PATCH 048/128] CMake: Indicate a clear signature in add_test.

---
 CMakeLists.txt | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 66aa96eaf..583151c2f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -282,7 +282,7 @@ if(ZLIB_INSTALL_LIBRARIES)
 endif(ZLIB_INSTALL_LIBRARIES)
 
 #============================================================================
-# Example binaries
+# Tests
 #============================================================================
 if(ZLIB_BUILD_TESTING)
     enable_testing()
@@ -290,7 +290,8 @@ if(ZLIB_BUILD_TESTING)
     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_test(NAME zlib_example
+            COMMAND zlib_example)
 
         add_executable(minigzip test/minigzip.c)
         target_compile_definitions(zlib
@@ -305,7 +306,8 @@ if(ZLIB_BUILD_TESTING)
                     LARGEFILE64_SOURCE=1
                     $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
             target_link_libraries(zlib_example64 ZLIB::ZLIB)
-            add_test(zlib_example64 zlib_example64)
+            add_test(NAME zlib_example64
+                COMMAND zlib_example64)
         endif(HAVE_OFF64_T)
     endif(ZLIB_BUILD_SHARED)
 
@@ -315,7 +317,8 @@ if(ZLIB_BUILD_TESTING)
         target_compile_definitions(zlib_static_example
             PRIVATE
                 $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
-        add_test(zlib_static_example zlib_static_example)
+        add_test(NAME zlib_static_example
+            COMMAND zlib_static_example)
 
         add_executable(static_minigzip test/minigzip.c)
         target_link_libraries(static_minigzip ZLIB::ZLIBSTATIC)
@@ -327,7 +330,8 @@ if(ZLIB_BUILD_TESTING)
                     LARGEFILE64_SOURCE=1
                     $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
             target_link_libraries(zlib_static_example64 ZLIB::ZLIBSTATIC)
-            add_test(zlib_static_example64 zlib_static_example64)
+            add_test(NAME zlib_static_example64
+                COMMAND zlib_static_example64)
         endif(HAVE_OFF64_T)
     endif(ZLIB_BUILD_STATIC)
 

From d7afcaa2be30fd2413d5f79293e5841579b56be9 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 11 Dec 2024 09:12:05 +0100
Subject: [PATCH 049/128] CMake: Shorten test names.

---
 test/CMakeLists.txt | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 4ea87861c..c5d8ad1e9 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_test(NAME zlib_test_install
+add_test(NAME zlib_install
     COMMAND ${CMAKE_COMMAND} --install ${zlib_BINARY_DIR}
         --prefix ${CMAKE_CURRENT_BINARY_DIR}/test_install
         --config $<CONFIG>
@@ -27,7 +27,7 @@ endif(GENERATOR)
 #
 # findpackage_test
 #
-add_test(NAME zlib_test_configure_find_package
+add_test(NAME zlib_configure_find_package
     COMMAND ${CMAKE_COMMAND}
         ${PLATFORM}
         -B${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build
@@ -40,12 +40,12 @@ add_test(NAME zlib_test_configure_find_package
         -G "${CMAKE_GENERATOR}"
         -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
 
-add_test(NAME zlib_test_build_find_package
+add_test(NAME zlib_build_find_package
     COMMAND ${CMAKE_COMMAND} --build .
     --config $<CONFIG>
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
 
-add_test(NAME zlib_test_test_find_package
+add_test(NAME zlib_test_find_package
     COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
 
@@ -67,7 +67,7 @@ set_tests_properties(zlib_test_test_find_package PROPERTIES
 #
 # add_subdirectory_test
 #
-add_test(NAME zlib_test_configure_add_subdirectory
+add_test(NAME zlib_configure_add_subdirectory
     COMMAND ${CMAKE_COMMAND}
     ${PLATFORM}
     -B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build
@@ -79,12 +79,12 @@ add_test(NAME zlib_test_configure_add_subdirectory
     -G "${CMAKE_GENERATOR}"
     -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
 
-add_test(NAME zlib_test_build_add_subdirectory
+add_test(NAME zlib_build_add_subdirectory
     COMMAND ${CMAKE_COMMAND} --build .
     --config $<CONFIG>
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
 
-add_test(NAME zlib_test_test_add_subdirectory
+add_test(NAME zlib_test_add_subdirectory
     COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
 
@@ -102,7 +102,7 @@ set_tests_properties(zlib_test_test_add_subdirectory PROPERTIES
 #
 # add_subdirectory_exclude_test
 #
-add_test(NAME zlib_test_configure_add_subdirectory_exclude
+add_test(NAME zlib_configure_add_subdirectory_exclude
     COMMAND ${CMAKE_COMMAND}
     ${PLATFORM}
     -B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build
@@ -114,12 +114,12 @@ add_test(NAME zlib_test_configure_add_subdirectory_exclude
     -G "${CMAKE_GENERATOR}"
     -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
 
-add_test(NAME zlib_test_build_add_subdirectory_exclude
+add_test(NAME zlib_build_add_subdirectory_exclude
     COMMAND ${CMAKE_COMMAND} --build .
     --config $<CONFIG>
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
 
-add_test(NAME zlib_test_test_add_subdirectory_exclude
+add_test(NAME zlib_test_add_subdirectory_exclude
     COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
 

From 920385267f71cd451754f83366f8bf2df1c9eb21 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 11 Dec 2024 09:12:30 +0100
Subject: [PATCH 050/128] CMake: Fix parallel testing.

---
 test/CMakeLists.txt | 29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index c5d8ad1e9..b274553da 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -4,6 +4,10 @@ add_test(NAME zlib_install
         --config $<CONFIG>
     WORKING_DIRECTORY ${zlib_BINARY_DIR})
 
+set_tests_properties(zlib_install
+    PROPERTIES
+        FIXTURES_SETUP zlib_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)
@@ -49,18 +53,15 @@ add_test(NAME zlib_test_find_package
     COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
 
-set_tests_properties(zlib_test_install PROPERTIES
-    FIXTURES_SETUP install)
-
-set_tests_properties(zlib_test_configure_find_package PROPERTIES
-    FIXTURES_REQUIRED install
+set_tests_properties(zlib_configure_find_package PROPERTIES
+    FIXTURES_REQUIRED zlib_install
     FIXTURES_SETUP fp_config)
 
-set_tests_properties(zlib_test_build_find_package PROPERTIES
+set_tests_properties(zlib_build_find_package PROPERTIES
     FIXTURES_REQUIRED fp_config
     FIXTURES_SETUP fp_build)
 
-set_tests_properties(zlib_test_test_find_package PROPERTIES
+set_tests_properties(zlib_test_find_package PROPERTIES
     FIXTURES_REQUIRED fp_build
     ENVIRONMENT CTEST_OUTPUT_ON_FAILURE=1)
 
@@ -88,14 +89,15 @@ add_test(NAME zlib_test_add_subdirectory
     COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
 
-set_tests_properties(zlib_test_configure_add_subdirectory PROPERTIES
+set_tests_properties(zlib_configure_add_subdirectory PROPERTIES
+    FIXTURES_REQUIRED zlib_install
     FIXTURES_SETUP as_config)
 
-set_tests_properties(zlib_test_build_add_subdirectory PROPERTIES
+set_tests_properties(zlib_build_add_subdirectory PROPERTIES
     FIXTURES_REQUIRED as_config
     FIXTURES_SETUP as_build)
 
-set_tests_properties(zlib_test_test_add_subdirectory PROPERTIES
+set_tests_properties(zlib_test_add_subdirectory PROPERTIES
     FIXTURES_REQUIRED as_build
     ENVIRONMENT CTEST_OUTPUT_ON_FAILURE=1)
 
@@ -123,13 +125,14 @@ add_test(NAME zlib_test_add_subdirectory_exclude
     COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
 
-set_tests_properties(zlib_test_configure_add_subdirectory_exclude PROPERTIES
+set_tests_properties(zlib_configure_add_subdirectory_exclude PROPERTIES
+    FIXTURES_REQUIRED zlib_install
     FIXTURES_SETUP asx_config)
 
-set_tests_properties(zlib_test_build_add_subdirectory_exclude PROPERTIES
+set_tests_properties(zlib_build_add_subdirectory_exclude PROPERTIES
     FIXTURES_REQUIRED as_config
     FIXTURES_SETUP asx_build)
 
-set_tests_properties(zlib_test_test_add_subdirectory_exclude PROPERTIES
+set_tests_properties(zlib_test_add_subdirectory_exclude PROPERTIES
     FIXTURES_REQUIRED asx_build
     ENVIRONMENT CTEST_OUTPUT_ON_FAILURE=1)

From 5ff476ee43fda6053ec5cc6dcf974aa3eb80d98e Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 11 Dec 2024 09:14:00 +0100
Subject: [PATCH 051/128] CMake: Add minizip.

---
 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 <stdlib.h>
+        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
+    $<$<BOOL:${WIN32}>:iowin32.c>
+    minizip.c
+    zip.c)
+
+set(MINIZIP_HDRS
+    crypt.h
+    ints.h
+    ioapi.h
+    $<$<BOOL:${WIN32}>:iowin32.h>
+    skipset.h
+     zip.h)
+
+set(MINIUNZIP_SRCS
+    ioapi.c
+    $<$<BOOL:${WIN32}>:iowin32.c>
+    miniunz.c
+    unzip.c
+    zip.c)
+
+set(MINIUNZIP_HDRS
+    crypt.h
+    ints.h
+    ioapi.h
+    $<$<BOOL:${WIN32}>: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
+        $<BUILD_INTERFACE:${minizip_SOURCE_DIR}>
+        $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
+    target_compile_definitions(libminizip
+        PRIVATE
+            $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
+            $<$<BOOL:${BZIP2_FOUND}>:HAVE_BZIP2=1>
+            $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
+            $<$<BOOL:${HAVE_UNISTD_H}>:HAVE_UNISTD_H=1>
+            $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>
+        PUBLIC
+            $<$<BOOL:${HAVE_OFF64_T}>:_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
+            $<$<BOOL:${BZIP2_FOUND}>:BZip2::BZip2>
+            ZLIB::ZLIB)
+
+    add_executable(minizip
+        ${MINIZIP_SRCS}
+        ${MINIZIP_HDRS})
+    target_compile_definitions(minizip
+        PRIVATE
+            $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
+            $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>)
+    target_link_libraries(minizip PRIVATE MINIZIP::MINIZIP)
+
+    add_executable(miniunzip
+        ${MINIUNZIP_SRCS}
+        ${MINIUNZIP_HDRS})
+    target_compile_definitions(miniunzip
+        PRIVATE
+            $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
+            $<$<BOOL:NOT:${HAVE_FOPEN64}>: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
+        $<BUILD_INTERFACE:${minizip_SOURCE_DIR}>
+        $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
+    target_compile_definitions(libminizipstatic
+        PRIVATE
+            $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
+            $<$<BOOL:${BZIP2_FOUND}>:HAVE_BZIP2=1>
+            $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
+            $<$<BOOL:${HAVE_UNISTD_H}>:HAVE_UNISTD_H=1>
+            $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>
+        PUBLIC
+            $<$<BOOL:${HAVE_OFF64_T}>:_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
+            $<$<BOOL:${BZIP2_FOUND}>:BZip2::BZip2>
+            ZLIB::ZLIBSTATIC)
+
+    add_executable(minizipstatic
+        ${MINIZIP_SRCS}
+        ${MINIZIP_HDRS})
+    target_compile_definitions(minizipstatic
+        PRIVATE
+            $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
+            $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>)
+    target_link_libraries(minizipstatic PRIVATE MINIZIP::MINIZIPSTATIC)
+
+    add_executable(miniunzipstatic
+        ${MINIUNZIP_SRCS}
+        ${MINIUNZIP_HDRS})
+    target_compile_definitions(miniunzipstatic
+        PRIVATE
+            $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
+            $<$<BOOL:NOT:${HAVE_FOPEN64}>: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  $<TARGET_FILE:libminizip>
+                COMPONENT Runtime
+                RENAME libminizip-${minizip_VERSION_MAJOR}.dll
+                DESTINATION "${CMAKE_INSTALL_BINDIR}")
+        endif(MINIZIP_INSTALL_COMPAT_DLL)
+
+        if(MSVC)
+            install(FILES $<TARGET_PDB_FILE:libminizip>
+                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 $<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=$<CONFIG>
+        -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 $<CONFIG>
+    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
+
+add_test(NAME minizip_test_find_package
+    COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
+    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=$<CONFIG>
+    -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 $<CONFIG>
+    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
+
+add_test(NAME minizip_test_add_subdirectory
+    COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
+    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=$<CONFIG>
+    -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 $<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 $<CONFIG>
+    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)
+

From aefb4b5b94be42ac148f2aaad36e23ca141618c0 Mon Sep 17 00:00:00 2001
From: Werner <led-control@vollstreckernet.de>
Date: Thu, 12 Dec 2024 06:35:57 +0100
Subject: [PATCH 052/128] CMake: Rename exports of minizip.

minizip-ng has prior art.
---
 contrib/minizip/CMakeLists.txt         | 24 ++++++++++++++++--------
 contrib/minizip/minizipConfig.cmake.in |  5 +++--
 2 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/contrib/minizip/CMakeLists.txt b/contrib/minizip/CMakeLists.txt
index 88ded2e9b..23abc7a22 100644
--- a/contrib/minizip/CMakeLists.txt
+++ b/contrib/minizip/CMakeLists.txt
@@ -121,7 +121,7 @@ if(MINIZIP_BUILD_SHARED)
     add_library(libminizip SHARED
         ${LIBMINIZIP_SRCS}
         ${LIBMINIZIP_HDRS})
-    add_library(MINIZIP::MINIZIP ALIAS libminizip)
+    add_library(MINIZIP::minizip ALIAS libminizip)
     target_include_directories(libminizip PUBLIC
         $<BUILD_INTERFACE:${minizip_SOURCE_DIR}>
         $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
@@ -141,7 +141,7 @@ if(MINIZIP_BUILD_SHARED)
     endif(NOT CYGWIN)
 
     set_target_properties(libminizip PROPERTIES
-        EXPORT_NAME MINIZIP
+        EXPORT_NAME minizip
         OUTPUT_NAME minizip
         VERSIOM ${minizip_VERSION}
         SOVERSION ${minizip_VERSION_MAJOR})
@@ -153,20 +153,24 @@ if(MINIZIP_BUILD_SHARED)
     add_executable(minizip
         ${MINIZIP_SRCS}
         ${MINIZIP_HDRS})
+    set_target_properties(minizip PROPERTIES
+        EXPORT_NAME minizip_executable)
     target_compile_definitions(minizip
         PRIVATE
             $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
             $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>)
-    target_link_libraries(minizip PRIVATE MINIZIP::MINIZIP)
+    target_link_libraries(minizip PRIVATE MINIZIP::minizip)
 
     add_executable(miniunzip
         ${MINIUNZIP_SRCS}
         ${MINIUNZIP_HDRS})
+    set_target_properties(miniunzip PROPERTIES
+        EXPORT_NAME miniunzip_executable)
     target_compile_definitions(miniunzip
         PRIVATE
             $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
             $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>)
-    target_link_libraries(miniunzip PRIVATE MINIZIP::MINIZIP)
+    target_link_libraries(miniunzip PRIVATE MINIZIP::minizip)
 endif(MINIZIP_BUILD_SHARED)
 
 if(MINIZIP_BUILD_STATIC)
@@ -174,7 +178,7 @@ if(MINIZIP_BUILD_STATIC)
     add_library(libminizipstatic STATIC
         ${LIBMINIZIP_SRCS}
         ${LIBMINIZIP_HDRS})
-    add_library(MINIZIP::MINIZIPSTATIC ALIAS libminizipstatic)
+    add_library(MINIZIP::minizipstatic ALIAS libminizipstatic)
     target_include_directories(libminizipstatic PUBLIC
         $<BUILD_INTERFACE:${minizip_SOURCE_DIR}>
         $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
@@ -188,7 +192,7 @@ if(MINIZIP_BUILD_STATIC)
         PUBLIC
             $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
     set_target_properties(libminizipstatic PROPERTIES
-        EXPORT_NAME MINIZIPSTATIC
+        EXPORT_NAME minizipstatic
         OUTPUT_NAME minizip${minizip_static_suffix})
 
     if(CYGWIN)
@@ -204,20 +208,24 @@ if(MINIZIP_BUILD_STATIC)
     add_executable(minizipstatic
         ${MINIZIP_SRCS}
         ${MINIZIP_HDRS})
+    set_target_properties(minizipstatic PROPERTIES
+        EXPORT_NAME minizip_static_executable)
     target_compile_definitions(minizipstatic
         PRIVATE
             $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
             $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>)
-    target_link_libraries(minizipstatic PRIVATE MINIZIP::MINIZIPSTATIC)
+    target_link_libraries(minizipstatic PRIVATE MINIZIP::minizipstatic)
 
     add_executable(miniunzipstatic
         ${MINIUNZIP_SRCS}
         ${MINIUNZIP_HDRS})
+    set_target_properties(miniunzipstatic PROPERTIES
+        EXPORT_NAME miniunzip_static_executable)
     target_compile_definitions(miniunzipstatic
         PRIVATE
             $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
             $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>)
-    target_link_libraries(miniunzipstatic PRIVATE MINIZIP::MINIZIPSTATIC)
+    target_link_libraries(miniunzipstatic PRIVATE MINIZIP::minizipstatic)
 endif(MINIZIP_BUILD_STATIC)
 
 if(MINIZIP_INSTALL)
diff --git a/contrib/minizip/minizipConfig.cmake.in b/contrib/minizip/minizipConfig.cmake.in
index 5221bfeaa..9c95fd620 100644
--- a/contrib/minizip/minizipConfig.cmake.in
+++ b/contrib/minizip/minizipConfig.cmake.in
@@ -1,5 +1,6 @@
 set(minizip_VERSION @minizip_VERSION@)
-set(MINIZIP_ENABLE_BZIP2 @MINIZIP_ENABLE_BZIP2@
+set(MINIZIP_ENABLE_BZIP2 @MINIZIP_ENABLE_BZIP2@)
 @PACKAGE_INIT@
-INCLUDE (${CMAKE_CURRENT_LIST_DIR}/minizip.cmake)
+include(CMakeFindDependencyMacro)
 find_dependency(zlib)
+INCLUDE (${CMAKE_CURRENT_LIST_DIR}/minizip.cmake)

From 5f98365bc9035ca1028b75a9bc05c58009155598 Mon Sep 17 00:00:00 2001
From: Werner <led-control@vollstreckernet.de>
Date: Sun, 15 Dec 2024 19:17:25 +0100
Subject: [PATCH 053/128] CMake: Install ints.h for minizip.

---
 contrib/minizip/CMakeLists.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/contrib/minizip/CMakeLists.txt b/contrib/minizip/CMakeLists.txt
index 23abc7a22..e43341964 100644
--- a/contrib/minizip/CMakeLists.txt
+++ b/contrib/minizip/CMakeLists.txt
@@ -76,6 +76,7 @@ set(LIBMINIZIP_SRCS
 
 set(LIBMINIZIP_HDRS
     crypt.h
+    ints.h
     ioapi.h
     mztools.h
     unzip.h

From dfaf27b0c82706dbee8e7258473414f4525cc8cb Mon Sep 17 00:00:00 2001
From: Werner <led-control@vollstreckernet.de>
Date: Sun, 15 Dec 2024 20:07:20 +0100
Subject: [PATCH 054/128] CMake: Change to FindZLIB and ZLIB.cmake.

---
 CMakeLists.txt                         | 10 +++++-----
 contrib/minizip/CMakeLists.txt         |  2 +-
 contrib/minizip/minizipConfig.cmake.in |  2 +-
 zlibConfig.cmake.in                    |  2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b777ad7af..65aef14e5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -252,22 +252,22 @@ if(ZLIB_INSTALL_LIBRARIES)
     endif(ZLIB_BUILD_STATIC)
 
     configure_package_config_file(${zlib_SOURCE_DIR}/zlibConfig.cmake.in
-        ${zlib_BINARY_DIR}/zlibConfig.cmake
+        ${zlib_BINARY_DIR}/ZLIBConfig.cmake
         INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib
         NO_CHECK_REQUIRED_COMPONENTS_MACRO)
 
     write_basic_package_version_file(
-        "${zlib_BINARY_DIR}/zlibConfigVersion.cmake"
+        "${zlib_BINARY_DIR}/ZLIBConfigVersion.cmake"
         VERSION "${zlib_VERSION}"
         COMPATIBILITY AnyNewerVersion)
 
     install(FILES
-        ${zlib_BINARY_DIR}/zlibConfig.cmake
-        ${zlib_BINARY_DIR}/zlibConfigVersion.cmake
+        ${zlib_BINARY_DIR}/ZLIBConfig.cmake
+        ${zlib_BINARY_DIR}/ZLIBConfigVersion.cmake
         DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
 
     install(EXPORT zlibExport
-        FILE zlib.cmake
+        FILE ZLIB.cmake
         DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib
         NAMESPACE ZLIB::)
 
diff --git a/contrib/minizip/CMakeLists.txt b/contrib/minizip/CMakeLists.txt
index e43341964..e5999518e 100644
--- a/contrib/minizip/CMakeLists.txt
+++ b/contrib/minizip/CMakeLists.txt
@@ -65,7 +65,7 @@ check_c_source_compiles(
 unset(CMAKE_REQUIRED_FLAGS)
 
 if(NOT TARGET ZLIB::ZLIB)
-    find_package(zlib REQUIRED)
+    find_package(ZLIB REQUIRED)
 endif(NOT TARGET ZLIB::ZLIB)
 
 set(LIBMINIZIP_SRCS
diff --git a/contrib/minizip/minizipConfig.cmake.in b/contrib/minizip/minizipConfig.cmake.in
index 9c95fd620..6596c0d81 100644
--- a/contrib/minizip/minizipConfig.cmake.in
+++ b/contrib/minizip/minizipConfig.cmake.in
@@ -2,5 +2,5 @@ set(minizip_VERSION @minizip_VERSION@)
 set(MINIZIP_ENABLE_BZIP2 @MINIZIP_ENABLE_BZIP2@)
 @PACKAGE_INIT@
 include(CMakeFindDependencyMacro)
-find_dependency(zlib)
+find_dependency(ZLIB)
 INCLUDE (${CMAKE_CURRENT_LIST_DIR}/minizip.cmake)
diff --git a/zlibConfig.cmake.in b/zlibConfig.cmake.in
index dfe6bbaed..8e64b6fc3 100644
--- a/zlibConfig.cmake.in
+++ b/zlibConfig.cmake.in
@@ -1,3 +1,3 @@
 set(zlib_VERSION @zlib_VERSION@)
 @PACKAGE_INIT@
-INCLUDE (${CMAKE_CURRENT_LIST_DIR}/zlib.cmake)
+INCLUDE (${CMAKE_CURRENT_LIST_DIR}/ZLIB.cmake)

From 99d41ee5c6acdf67e0271bcac060e31adf7c52e5 Mon Sep 17 00:00:00 2001
From: Werner <led-control@vollstreckernet.de>
Date: Sun, 15 Dec 2024 21:05:49 +0100
Subject: [PATCH 055/128] CMake: Make minizip search for config.

---
 contrib/minizip/minizipConfig.cmake.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/minizip/minizipConfig.cmake.in b/contrib/minizip/minizipConfig.cmake.in
index 6596c0d81..b23454f2b 100644
--- a/contrib/minizip/minizipConfig.cmake.in
+++ b/contrib/minizip/minizipConfig.cmake.in
@@ -2,5 +2,5 @@ set(minizip_VERSION @minizip_VERSION@)
 set(MINIZIP_ENABLE_BZIP2 @MINIZIP_ENABLE_BZIP2@)
 @PACKAGE_INIT@
 include(CMakeFindDependencyMacro)
-find_dependency(ZLIB)
+find_dependency(ZLIB CONFIG)
 INCLUDE (${CMAKE_CURRENT_LIST_DIR}/minizip.cmake)

From 5163cb6d3bd6fa72d7be7213f786455778a5e8f7 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Sun, 22 Dec 2024 16:10:22 +0100
Subject: [PATCH 056/128] CMake: Move testing into test/CMakeLists.txt.

Use the right environment to find the libraries.
---
 CMakeLists.txt      | 49 ------------------------------
 test/CMakeLists.txt | 73 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 73 insertions(+), 49 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 65aef14e5..81943b9cd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -287,55 +287,6 @@ endif(ZLIB_INSTALL_LIBRARIES)
 #============================================================================
 if(ZLIB_BUILD_TESTING)
     enable_testing()
-
-    if(ZLIB_BUILD_SHARED)
-        add_executable(zlib_example test/example.c)
-        target_link_libraries(zlib_example ZLIB::ZLIB)
-        add_test(NAME zlib_example
-            COMMAND zlib_example)
-
-        add_executable(minigzip test/minigzip.c)
-        target_compile_definitions(zlib
-            PRIVATE
-                $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
-        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
-                    $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
-            target_link_libraries(zlib_example64 ZLIB::ZLIB)
-            add_test(NAME zlib_example64
-                COMMAND zlib_example64)
-        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)
-        target_compile_definitions(zlib_static_example
-            PRIVATE
-                $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
-        add_test(NAME zlib_static_example
-            COMMAND 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
-                    $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
-            target_link_libraries(zlib_static_example64 ZLIB::ZLIBSTATIC)
-            add_test(NAME zlib_static_example64
-                COMMAND zlib_static_example64)
-        endif(HAVE_OFF64_T)
-    endif(ZLIB_BUILD_STATIC)
-
     add_subdirectory(test)
 endif(ZLIB_BUILD_TESTING)
 
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index b274553da..15e8c75a6 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,3 +1,76 @@
+function (ZLIB_findTestEnv testName)
+        set (testEnv "PATH=")
+
+        if (MSVC OR MINGW)
+                set (separator "\\\;")
+        else()
+                set (separator ":")
+        endif()
+
+        string (APPEND testEnv "$<TARGET_FILE_DIR:ZLIB::ZLIB>${separator}")
+        string (APPEND testEnv "$ENV{PATH}")
+
+        set_tests_properties (${testName} PROPERTIES
+                ENVIRONMENT "${testEnv}"
+        )
+endfunction()
+
+if(ZLIB_BUILD_SHARED)
+    add_executable(zlib_example example.c)
+    target_link_libraries(zlib_example ZLIB::ZLIB)
+    add_test(NAME zlib_example
+        COMMAND zlib_example)
+
+    add_executable(minigzip minigzip.c)
+    target_compile_definitions(zlib
+        PRIVATE
+            $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
+    target_link_libraries(minigzip ZLIB::ZLIB)
+
+    if (MSVC OR MSYS OR MINGW OR CYGWIN)
+        ZLIB_findTestEnv (zlib_example)
+    endif (MSVC OR MSYS OR MINGW OR CYGWIN)
+
+    if(HAVE_OFF64_T)
+        add_executable(zlib_example64 example.c)
+        target_compile_definitions(zlib_example64
+            PRIVATE
+                LARGEFILE64_SOURCE=1
+                $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
+        target_link_libraries(zlib_example64 ZLIB::ZLIB)
+        add_test(NAME zlib_example64
+            COMMAND zlib_example64)
+
+        if (MSVC OR MSYS OR MINGW OR CYGWIN)
+            ZLIB_findTestEnv (zlib_example64)
+        endif (MSVC OR MSYS OR MINGW OR CYGWIN)
+    endif(HAVE_OFF64_T)
+endif(ZLIB_BUILD_SHARED)
+
+if(ZLIB_BUILD_STATIC)
+    add_executable(zlib_static_example example.c)
+    target_link_libraries(zlib_static_example ZLIB::ZLIBSTATIC)
+    target_compile_definitions(zlib_static_example
+        PRIVATE
+            $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
+    add_test(NAME zlib_static_example
+        COMMAND zlib_static_example)
+
+    add_executable(static_minigzip minigzip.c)
+    target_link_libraries(static_minigzip ZLIB::ZLIBSTATIC)
+
+    if(HAVE_OFF64_T)
+        add_executable(zlib_static_example64 example.c)
+        target_compile_definitions(zlib_static_example64
+            PRIVATE
+                LARGEFILE64_SOURCE=1
+                $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
+        target_link_libraries(zlib_static_example64 ZLIB::ZLIBSTATIC)
+        add_test(NAME zlib_static_example64
+            COMMAND zlib_static_example64)
+    endif(HAVE_OFF64_T)
+endif(ZLIB_BUILD_STATIC)
+
 add_test(NAME zlib_install
     COMMAND ${CMAKE_COMMAND} --install ${zlib_BINARY_DIR}
         --prefix ${CMAKE_CURRENT_BINARY_DIR}/test_install

From d3ab1df503abffbc2480d10c110e955bad803e0a Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Tue, 24 Dec 2024 21:42:47 +0100
Subject: [PATCH 057/128] CMake: Test minizip in the workflows.

---
 .github/workflows/c-std.yml | 4 ++--
 .github/workflows/cmake.yml | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/c-std.yml b/.github/workflows/c-std.yml
index 8377db4ee..64a1c86f6 100644
--- a/.github/workflows/c-std.yml
+++ b/.github/workflows/c-std.yml
@@ -133,7 +133,7 @@ jobs:
     - name: Generate project files (cmake)
       if: matrix.builder == 'cmake'
       run: |
-        cmake -S . -B . -D CMAKE_BUILD_TYPE=Release ${{ matrix.os.cmake-opt }}
+        cmake -S . -B . -D CMAKE_BUILD_TYPE=Release ${{ matrix.os.cmake-opt }} -DZLIB_BUILD_MINIZIP=ON
       env:
         CC: ${{ matrix.compiler }}
         CFLAGS: -std=${{ matrix.std.value }} ${{ matrix.arch.compiler-opt }} -Werror -Wall -Wextra
@@ -196,7 +196,7 @@ jobs:
 
     - name: Generate project files (cmake)
       run: |
-        cmake -S . -B . ${{ matrix.arch.value }} -D CMAKE_BUILD_TYPE=Release
+        cmake -S . -B . ${{ matrix.arch.value }} -D CMAKE_BUILD_TYPE=Release -DZLIB_BUILD_MINIZIP=ON
       env:
         CC: ${{ matrix.compiler }}
         CFLAGS: /WX ${{ matrix.std.value }}
diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml
index 36fb2493d..a157124d0 100644
--- a/.github/workflows/cmake.yml
+++ b/.github/workflows/cmake.yml
@@ -75,7 +75,7 @@ jobs:
         choco install --no-progress ninja ${{ matrix.packages }}
 
     - name: Generate project files
-      run: cmake -S ${{ matrix.src-dir || '.' }} -B ${{ matrix.build-dir || '.' }} ${{ matrix.cmake-args }} -D CMAKE_BUILD_TYPE=${{ matrix.build-config || 'Release' }}
+      run: cmake -S ${{ matrix.src-dir || '.' }} -B ${{ matrix.build-dir || '.' }} ${{ matrix.cmake-args }} -D CMAKE_BUILD_TYPE=${{ matrix.build-config || 'Release' }} -DZLIB_BUILD_MINIZIP=ON
       env:
         CC: ${{ matrix.compiler }}
         CFLAGS: ${{ matrix.cflags }}

From 27198174ca18157eba7b4e7f2625116506284b37 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Tue, 24 Dec 2024 21:43:52 +0100
Subject: [PATCH 058/128] CMake: Correct target to minizip.

---
 test/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 15e8c75a6..c820ed534 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -22,7 +22,7 @@ if(ZLIB_BUILD_SHARED)
         COMMAND zlib_example)
 
     add_executable(minigzip minigzip.c)
-    target_compile_definitions(zlib
+    target_compile_definitions(minigzip
         PRIVATE
             $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
     target_link_libraries(minigzip ZLIB::ZLIB)

From 93457606bf297c3febcfa5a475ad16007542cd3f Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Tue, 24 Dec 2024 21:44:05 +0100
Subject: [PATCH 059/128] CMake: Add inflate coverage test.

---
 test/CMakeLists.txt | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index c820ed534..3fffe9e21 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -59,6 +59,41 @@ if(ZLIB_BUILD_STATIC)
     add_executable(static_minigzip minigzip.c)
     target_link_libraries(static_minigzip ZLIB::ZLIBSTATIC)
 
+    if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR
+        ${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
+        if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
+            find_program(GCOV_EXECUTABLE gcov)
+        endif(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
+
+        if(${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
+            set(llvm_names llvm_cov)
+
+            foreach(ver RANGE 11 99)
+              list(APPEND llvm_names llvm-cov-${ver})
+            endforeach(ver RANGE 11 99)
+
+            find_program(GCOV_EXECUTABLE NAMES ${llvm_names})
+            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
+                $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
+            add_test (NAME coverage COMMAND infcover)
+            set (INFCOVER_DIR
+                ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/infcover.dir)
+            add_test (NAME coverage-summary
+                COMMAND ${GCOV_EXECUTABLE} ${llvm_option}
+                    ${CMAKE_CURRENT_SOURCE_DIR}/infcover.c
+                    -o ${INFCOVER_DIR}/infcover.c.gcda)
+            set_tests_properties(coverage-summary PROPERTIES DEPENDS incover)
+    endif(${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR
+        ${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
+
     if(HAVE_OFF64_T)
         add_executable(zlib_static_example64 example.c)
         target_compile_definitions(zlib_static_example64

From 0b9b43b45b1d3de90139e9199383432e72a96579 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Tue, 24 Dec 2024 23:11:22 +0100
Subject: [PATCH 060/128] Fix inflate coverage test in Makefile.in.

---
 Makefile.in | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index c00625bb0..6bb6af533 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -113,15 +113,15 @@ test64: all64
 	@rm -f tmp64_$$
 
 infcover.o: $(SRCDIR)test/infcover.c $(SRCDIR)zlib.h zconf.h
-	$(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/infcover.c
+	$(CC) $(CFLAGS) $(ZINCOUT) -c -coverage -o $@ $(SRCDIR)test/infcover.c
 
 infcover: infcover.o libz.a
-	$(CC) $(CFLAGS) -o $@ infcover.o libz.a
+	$(CC) $(CFLAGS) -coverage -o $@ infcover.o libz.a
 
 cover: infcover
 	rm -f *.gcda
 	${QEMU_RUN} ./infcover
-	gcov inf*.c
+	gcov inf*.c -o ./infcover.gcda
 
 libz.a: $(OBJS)
 	$(AR) $(ARFLAGS) $@ $(OBJS)

From d80817ac954487599ec10f533afcfa083e81510c Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 25 Dec 2024 00:51:02 +0100
Subject: [PATCH 061/128] CMake: Restore leading underscore in
 _LARGEFILE64_SOURCE.

---
 CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 81943b9cd..b9b5b92da 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -204,7 +204,7 @@ if(ZLIB_BUILD_STATIC)
             $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
             $<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>
         PUBLIC
-            $<$<BOOL:${HAVE_OFF64_T}>:LARGEFILE64_SOURCE=1>)
+            $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
     set_target_properties(zlibstatic PROPERTIES
         EXPORT_NAME ZLIBSTATIC
         OUTPUT_NAME z${zlib_static_suffix})

From 3b613563d30d99adcb8410af36b1ffc928bc947b Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 25 Dec 2024 09:07:14 +0100
Subject: [PATCH 062/128] CMake: Prefix coverage test name with zlib.

---
 test/CMakeLists.txt | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 3fffe9e21..1f399f4b7 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -61,6 +61,9 @@ if(ZLIB_BUILD_STATIC)
 
     if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR
         ${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
+        set(CFLAGS_OLD ${CMAKE_C_FLAGS})
+        set({CMAKE_C_FLAGS "" CACHE STRING "" FORCE)
+
         if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
             find_program(GCOV_EXECUTABLE gcov)
         endif(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
@@ -83,14 +86,15 @@ if(ZLIB_BUILD_STATIC)
         target_compile_definitions(infcover
             PRIVATE
                 $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
-            add_test (NAME coverage COMMAND infcover)
-            set (INFCOVER_DIR
-                ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/infcover.dir)
-            add_test (NAME coverage-summary
-                COMMAND ${GCOV_EXECUTABLE} ${llvm_option}
-                    ${CMAKE_CURRENT_SOURCE_DIR}/infcover.c
-                    -o ${INFCOVER_DIR}/infcover.c.gcda)
-            set_tests_properties(coverage-summary PROPERTIES DEPENDS incover)
+        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(${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR
         ${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
 

From 1869359d44f61df55dea4893a0a7495189ac3749 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 25 Dec 2024 09:55:07 +0100
Subject: [PATCH 063/128] CMake: Split the builds of infcover and minizip in
 workflow.

---
 .github/workflows/c-std.yml | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/.github/workflows/c-std.yml b/.github/workflows/c-std.yml
index 64a1c86f6..a0e6a9e25 100644
--- a/.github/workflows/c-std.yml
+++ b/.github/workflows/c-std.yml
@@ -133,18 +133,30 @@ jobs:
     - name: Generate project files (cmake)
       if: matrix.builder == 'cmake'
       run: |
-        cmake -S . -B . -D CMAKE_BUILD_TYPE=Release ${{ matrix.os.cmake-opt }} -DZLIB_BUILD_MINIZIP=ON
+        cmake -S . -B ./build1 -D CMAKE_BUILD_TYPE=Release ${{ matrix.os.cmake-opt }} -DZLIB_BUILD_TESTING=OFF
       env:
         CC: ${{ matrix.compiler }}
         CFLAGS: -std=${{ matrix.std.value }} ${{ matrix.arch.compiler-opt }} -Werror -Wall -Wextra
 
+    - name: Generate project files with tests (cmake)
+      if: matrix.builder == 'cmake'
+      run: |
+        cmake -S . -B ./build2 -D CMAKE_BUILD_TYPE=Release ${{ matrix.os.cmake-opt }} -DZLIB_BUILD_MINIZIP=ON
+      env:
+        CC: ${{ matrix.compiler }}
+        CFLAGS: -std=${{ matrix.std.value }} ${{ matrix.arch.compiler-opt }} -Wall -Wextra
+
     - name: Compile source code (cmake)
       if: matrix.builder == 'cmake'
-      run: cmake --build . --config Release
+      run: cmake --build ./build1 --config Release
+
+    - name: Compile source code with tests (cmake)
+      if: matrix.builder == 'cmake'
+      run: cmake --build ./build --config Release
 
     - name: Run test cases (cmake)
       if: matrix.builder == 'cmake'
-      run: ctest -C Release --output-on-failure --max-width 120
+      run: ctest ./build2 -C Release --output-on-failure --max-width 120
 
 
   msvc:
@@ -196,13 +208,23 @@ jobs:
 
     - name: Generate project files (cmake)
       run: |
-        cmake -S . -B . ${{ matrix.arch.value }} -D CMAKE_BUILD_TYPE=Release -DZLIB_BUILD_MINIZIP=ON
+        cmake -S . -B ./build1 ${{ matrix.arch.value }} -D CMAKE_BUILD_TYPE=Release -DZLIB_BUILD_TESTING=OFF
       env:
         CC: ${{ matrix.compiler }}
         CFLAGS: /WX ${{ matrix.std.value }}
 
+    - name: Generate project files with tests (cmake)
+      run: |
+        cmake -S . -B ./build2 ${{ matrix.arch.value }} -D CMAKE_BUILD_TYPE=Release -DZLIB_BUILD_MINIZIP=ON
+      env:
+        CC: ${{ matrix.compiler }}
+        CFLAGS: ${{ matrix.std.value }}
+
     - name: Compile source code (cmake)
-      run: cmake --build . --config Release -v
+      run: cmake --build ./build1 --config Release -v
+
+    - name: Compile source code with tests(cmake)
+      run: cmake --build ./build2 --config Release -v
 
     - name: Run test cases (cmake)
-      run: ctest -C Release --output-on-failure --max-width 120
+      run: ctest ./build2 -C Release --output-on-failure --max-width 120

From c7e9d282e7a92e881bf26972c7c167428dabf453 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 25 Dec 2024 09:55:27 +0100
Subject: [PATCH 064/128] CMake: Do just one build with -Werror in workflow.

---
 .github/workflows/cmake.yml | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml
index a157124d0..d8f97f8d6 100644
--- a/.github/workflows/cmake.yml
+++ b/.github/workflows/cmake.yml
@@ -11,59 +11,59 @@ jobs:
           - name: Ubuntu GCC
             os: ubuntu-latest
             compiler: gcc
-            cflags: -Werror -Wall -Wextra
+            cflags: -Wall -Wextra
 
           # Test out of source builds
           - name: Ubuntu GCC OSB
             os: ubuntu-latest
             compiler: gcc
-            cflags: -Werror -Wall -Wextra
+            cflags: -Wall -Wextra
             build-dir: ../build
             src-dir: ../zlib
 
           - name: Ubuntu GCC -O3
             os: ubuntu-latest
             compiler: gcc
-            cflags: -O3 -Werror -Wall -Wextra
+            cflags: -O3 -Wall -Wextra
 
           - name: Ubuntu Clang
             os: ubuntu-latest
             compiler: clang
-            cflags: -Werror -Wall -Wextra
+            cflags: -Wall -Wextra
 
           - name: Ubuntu Clang Debug
             os: ubuntu-latest
             compiler: clang
-            cflags: -Werror -Wall -Wextra
+            cflags: -Wall -Wextra
             build-config: Debug
 
           - name: Windows MSVC Win32
             os: windows-latest
             compiler: cl
-            cflags: /WX /W3
+            cflags: /W3
             cmake-args: -A Win32
 
           - name: Windows MSVC Win64
             os: windows-latest
             compiler: cl
-            cflags: /WX /W3
+            cflags: /W3
             cmake-args: -A x64
 
           - name: Windows GCC
             os: windows-latest
             compiler: gcc
-            cflags: -Werror -Wall -Wextra
+            cflags: -Wall -Wextra
             cmake-args: -G Ninja
 
           - name: macOS Clang
             os: macos-latest
             compiler: clang
-            cflags: -Werror -Wall -Wextra
+            cflags: -Wall -Wextra
 
           - name: macOS GCC
             os: macos-latest
             compiler: gcc-12
-            cflags: -Werror -Wall -Wextra
+            cflags: -Wall -Wextra
 
     steps:
     - name: Checkout repository

From c9467bd5f8864d67769c709193f47937aa8b0234 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 25 Dec 2024 09:56:21 +0100
Subject: [PATCH 065/128] Correct QEMU package name to qemu-system in workflow.

As in Ubuntu 24.04.
---
 .github/workflows/configure.yml | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/.github/workflows/configure.yml b/.github/workflows/configure.yml
index 7789095e2..857a1883a 100644
--- a/.github/workflows/configure.yml
+++ b/.github/workflows/configure.yml
@@ -26,7 +26,7 @@ jobs:
             compiler: arm-linux-gnueabi-gcc
             configure-args: --warn
             chost: arm-linux-gnueabi
-            packages: qemu qemu-user gcc-arm-linux-gnueabi libc-dev-armel-cross
+            packages: qemu-system qemu-user gcc-arm-linux-gnueabi libc-dev-armel-cross
             qemu-run: qemu-arm -L /usr/arm-linux-gnueabi
 
           - name: Ubuntu GCC ARM HF
@@ -34,7 +34,7 @@ jobs:
             compiler: arm-linux-gnueabihf-gcc
             configure-args: --warn
             chost: arm-linux-gnueabihf
-            packages: qemu qemu-user gcc-arm-linux-gnueabihf libc-dev-armhf-cross
+            packages: qemu-system qemu-user gcc-arm-linux-gnueabihf libc-dev-armhf-cross
             qemu-run: qemu-arm -L /usr/arm-linux-gnueabihf
 
           - name: Ubuntu GCC AARCH64
@@ -42,7 +42,7 @@ jobs:
             compiler: aarch64-linux-gnu-gcc
             configure-args: --warn
             chost: aarch64-linux-gnu
-            packages: qemu qemu-user gcc-aarch64-linux-gnu libc-dev-arm64-cross
+            packages: qemu-system qemu-user gcc-aarch64-linux-gnu libc-dev-arm64-cross
             qemu-run: qemu-aarch64 -L /usr/aarch64-linux-gnu
 
           - name: Ubuntu GCC PPC
@@ -50,7 +50,7 @@ jobs:
             compiler: powerpc-linux-gnu-gcc
             configure-args: --warn --static
             chost: powerpc-linux-gnu
-            packages: qemu qemu-user gcc-powerpc-linux-gnu libc-dev-powerpc-cross
+            packages: qemu-system qemu-user gcc-powerpc-linux-gnu libc-dev-powerpc-cross
             qemu-run: qemu-ppc -L /usr/powerpc-linux-gnu
             cflags: -static
             ldflags: -static
@@ -60,7 +60,7 @@ jobs:
             compiler: powerpc64-linux-gnu-gcc
             configure-args: --warn --static
             chost: powerpc-linux-gnu
-            packages: qemu qemu-user gcc-powerpc64-linux-gnu libc-dev-ppc64-cross
+            packages: qemu-system qemu-user gcc-powerpc64-linux-gnu libc-dev-ppc64-cross
             qemu-run: qemu-ppc64 -L /usr/powerpc64-linux-gnu
             cflags: -static
             ldflags: -static
@@ -70,7 +70,7 @@ jobs:
             compiler: powerpc64le-linux-gnu-gcc
             configure-args: --warn
             chost: powerpc64le-linux-gnu
-            packages: qemu qemu-user gcc-powerpc64le-linux-gnu libc-dev-ppc64el-cross
+            packages: qemu-system qemu-user gcc-powerpc64le-linux-gnu libc-dev-ppc64el-cross
             qemu-run: qemu-ppc64le -L /usr/powerpc64le-linux-gnu
 
           - name: Ubuntu GCC S390X
@@ -78,7 +78,7 @@ jobs:
             compiler: s390x-linux-gnu-gcc
             configure-args: --warn --static
             chost: s390x-linux-gnu
-            packages: qemu qemu-user gcc-s390x-linux-gnu libc-dev-s390x-cross
+            packages: qemu-system qemu-user gcc-s390x-linux-gnu libc-dev-s390x-cross
             qemu-run: qemu-s390x -L /usr/s390x-linux-gnu
             cflags: -static
             ldflags: -static

From a5db296ace453aa82ba1ededc0d6d458650f5668 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 25 Dec 2024 10:02:38 +0100
Subject: [PATCH 066/128] CMake: Increase CMake version to 3.10 for tests.

And correct package name to ZLIB.
---
 test/add_subdirectory_exclude_test.cmake.in | 2 +-
 test/add_subdirectory_test.cmake.in         | 2 +-
 test/find_package_test.cmake.in             | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/test/add_subdirectory_exclude_test.cmake.in b/test/add_subdirectory_exclude_test.cmake.in
index 9dd9d35e7..9516546a8 100644
--- a/test/add_subdirectory_exclude_test.cmake.in
+++ b/test/add_subdirectory_exclude_test.cmake.in
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.5)
+cmake_minimum_required(VERSION 3.10)
 
 project(zlib_find_package_test
     LANGUAGES C
diff --git a/test/add_subdirectory_test.cmake.in b/test/add_subdirectory_test.cmake.in
index c10f7095c..72933bacb 100644
--- a/test/add_subdirectory_test.cmake.in
+++ b/test/add_subdirectory_test.cmake.in
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.5)
+cmake_minimum_required(VERSION 3.10)
 
 project(zlib_find_package_test
     LANGUAGES C
diff --git a/test/find_package_test.cmake.in b/test/find_package_test.cmake.in
index 42f3c19e7..2adab4c11 100644
--- a/test/find_package_test.cmake.in
+++ b/test/find_package_test.cmake.in
@@ -1,11 +1,11 @@
-cmake_minimum_required(VERSION 3.5)
+cmake_minimum_required(VERSION 3.10)
 
 project(zlib_find_package_test
     LANGUAGES C
     VERSION ${zlib_VERSION})
 
 enable_testing()
-find_package(zlib ${zlib_VERSION} CONFIG REQUIRED)
+find_package(ZLIB ${zlib_VERSION} CONFIG REQUIRED)
 
 if(${ZLIB_BUILD_SHARED})
     add_executable(test_example ${zlib_SOURCE_DIR}/test/example.c)

From 9ddf1b4bc56d0183c4a41868ecc8515f5fc2d897 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 25 Dec 2024 10:06:14 +0100
Subject: [PATCH 067/128] CMake: Correct build directory for second workflow
 run.

---
 .github/workflows/c-std.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/c-std.yml b/.github/workflows/c-std.yml
index a0e6a9e25..bc9311045 100644
--- a/.github/workflows/c-std.yml
+++ b/.github/workflows/c-std.yml
@@ -152,7 +152,7 @@ jobs:
 
     - name: Compile source code with tests (cmake)
       if: matrix.builder == 'cmake'
-      run: cmake --build ./build --config Release
+      run: cmake --build ./build2 --config Release
 
     - name: Run test cases (cmake)
       if: matrix.builder == 'cmake'

From 44919160dee8de9f6bf03e1af0162be988dcd493 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 25 Dec 2024 12:52:53 +0100
Subject: [PATCH 068/128] Adjust coverage testing to the llvm gcov calling
 convention.

---
 Makefile.in |  4 +++-
 configure   | 29 ++++++++++++++++++++++++-----
 2 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 6bb6af533..e6edd0d6e 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -13,6 +13,8 @@
 #    make install prefix=$HOME
 
 CC=cc
+GCOV=GCOV
+LLVM_GCOV_FLAG=LLMV_GCOV_FLAG
 
 CFLAGS=-O
 #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
@@ -121,7 +123,7 @@ infcover: infcover.o libz.a
 cover: infcover
 	rm -f *.gcda
 	${QEMU_RUN} ./infcover
-	gcov inf*.c -o ./infcover.gcda
+	${GCOV} ${LLVM_GCOV_FLAG} inf*.c -o ./infcover.gcda
 
 libz.a: $(OBJS)
 	$(AR) $(ARFLAGS) $@ $(OBJS)
diff --git a/configure b/configure
index 54c802e23..dcf1a08bb 100755
--- a/configure
+++ b/configure
@@ -87,6 +87,7 @@ zprefix=0
 zconst=0
 build64=0
 gcc=0
+clang=0
 warn=0
 debug=0
 address=0
@@ -185,14 +186,31 @@ else
 fi
 
 case "$cc" in
-  *gcc*) gcc=1 ;;
-  *clang*) gcc=1 ;;
+  *gcc*) gcc=1
+    GCOV="gcov" ;;
+  *clang*) gcc=1
+    clang=1 ;;
 esac
 case `$cc -v 2>&1` in
-  *gcc*) gcc=1 ;;
-  *clang*) gcc=1 ;;
+  *gcc*) gcc=1
+    GCOV="gcov" ;;
+  *clang*) gcc=1
+    clang=1 ;;
 esac
 
+if test "$clang" -eq 1; then
+  clangV=`echo "$cc" | sed -e 's/^.*-//'`
+  if `llvm-cov-${clangV} --version > /dev/null`; then
+    GCOV="llvm-cov-${clangV}"
+    LLVM_GCOV_FLAG="gcov"
+    echo "Using ${GCOV} for coverage"
+  else
+    cover=0
+    LLVM_GCOV_FLAG=""
+    echo "Deactivating cover as no suitable gcov can be found"
+  fi
+fi
+
 show $cc -c $test.c
 if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
   echo ... using gcc >> configure.log
@@ -620,7 +638,6 @@ fi
 
 # if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X
 if test $cover -eq 1; then
-  CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"
   if test -n "$GCC_CLASSIC"; then
     CC=$GCC_CLASSIC
   fi
@@ -872,6 +889,8 @@ echo uname = $uname >> configure.log
 # update Makefile with the configure results
 sed < ${SRCDIR}Makefile.in "
 /^CC *=/s#=.*#=$CC#
+/^GCOV *=/s#=.*#=$GCOV#
+/^LLVM_GCOV_FLAG *=/s#=.*#=$LLVM_GCOV_FLAG#
 /^CFLAGS *=/s#=.*#=$CFLAGS#
 /^SFLAGS *=/s#=.*#=$SFLAGS#
 /^LDFLAGS *=/s#=.*#=$LDFLAGS#

From 121e4168b911a88128581b0679e80b5b3bbe6df2 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 25 Dec 2024 13:02:38 +0100
Subject: [PATCH 069/128] CMake: Increase CMake version to 3.12 for minizip
 tests.

And look for ZLIB package.
---
 contrib/minizip/test/add_subdirectory_exclude_test.cmake.in | 2 +-
 contrib/minizip/test/add_subdirectory_test.cmake.in         | 2 +-
 contrib/minizip/test/find_package_test.cmake.in             | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in b/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in
index 9dd9d35e7..92d6a4d74 100644
--- a/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in
+++ b/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.5)
+cmake_minimum_required(VERSION 3.12)
 
 project(zlib_find_package_test
     LANGUAGES C
diff --git a/contrib/minizip/test/add_subdirectory_test.cmake.in b/contrib/minizip/test/add_subdirectory_test.cmake.in
index c10f7095c..fc2a9e0cb 100644
--- a/contrib/minizip/test/add_subdirectory_test.cmake.in
+++ b/contrib/minizip/test/add_subdirectory_test.cmake.in
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.5)
+cmake_minimum_required(VERSION 3.12)
 
 project(zlib_find_package_test
     LANGUAGES C
diff --git a/contrib/minizip/test/find_package_test.cmake.in b/contrib/minizip/test/find_package_test.cmake.in
index 42f3c19e7..3df1edecc 100644
--- a/contrib/minizip/test/find_package_test.cmake.in
+++ b/contrib/minizip/test/find_package_test.cmake.in
@@ -1,11 +1,11 @@
-cmake_minimum_required(VERSION 3.5)
+cmake_minimum_required(VERSION 3.12)
 
 project(zlib_find_package_test
     LANGUAGES C
     VERSION ${zlib_VERSION})
 
 enable_testing()
-find_package(zlib ${zlib_VERSION} CONFIG REQUIRED)
+find_package(ZLIB ${zlib_VERSION} CONFIG REQUIRED)
 
 if(${ZLIB_BUILD_SHARED})
     add_executable(test_example ${zlib_SOURCE_DIR}/test/example.c)

From 2408dedfa538b90a59066cafcbbbd6ad7c7bd632 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 25 Dec 2024 14:51:14 +0100
Subject: [PATCH 070/128] Support clang without version suffix for coverage
 testing.

---
 configure | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/configure b/configure
index dcf1a08bb..03a9e78bc 100755
--- a/configure
+++ b/configure
@@ -199,15 +199,29 @@ case `$cc -v 2>&1` in
 esac
 
 if test "$clang" -eq 1; then
-  clangV=`echo "$cc" | sed -e 's/^.*-//'`
-  if `llvm-cov-${clangV} --version > /dev/null`; then
-    GCOV="llvm-cov-${clangV}"
+  if test "$cc" = "clang"; then
+    if `llvm-cov --version > /dev/null`; then
+      GCOV="llvm-cov-${clangV}"
+      LLVM_GCOV_FLAG="gcov"
+    else
+      cover=0
+      LLVM_GCOV_FLAG=""
+      echo "Deactivating cover as no suitable gcov can be found"
+    fi
+    GCOV="llvm-cov"
     LLVM_GCOV_FLAG="gcov"
     echo "Using ${GCOV} for coverage"
   else
-    cover=0
-    LLVM_GCOV_FLAG=""
-    echo "Deactivating cover as no suitable gcov can be found"
+    clangV=`echo "$cc" | sed -e 's/^.*-//'`
+    if `llvm-cov-${clangV} --version > /dev/null`; then
+      GCOV="llvm-cov-${clangV}"
+      LLVM_GCOV_FLAG="gcov"
+      echo "Using ${GCOV} for coverage"
+    else
+      cover=0
+      LLVM_GCOV_FLAG=""
+      echo "Deactivating cover as no suitable gcov can be found"
+    fi
   fi
 fi
 

From 039c3610e5fce300b2dd5a335394677b131512b5 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 25 Dec 2024 14:54:22 +0100
Subject: [PATCH 071/128] Remove -Werror from configure workflow.

---
 .github/workflows/configure.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/configure.yml b/.github/workflows/configure.yml
index 857a1883a..f19272c72 100644
--- a/.github/workflows/configure.yml
+++ b/.github/workflows/configure.yml
@@ -110,7 +110,7 @@ jobs:
         ${{ matrix.src-dir || '.' }}/configure ${{ matrix.configure-args }}
       env:
         CC: ${{ matrix.compiler }}
-        CFLAGS: ${{ matrix.cflags }} -Werror
+        CFLAGS: ${{ matrix.cflags }}
         LDFLAGS: ${{ matrix.ldflags }}
         CHOST: ${{ matrix.chost }}
 

From e677f1f1c71231ba1befb9da6ed02b6db38dedc3 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 25 Dec 2024 18:52:44 +0100
Subject: [PATCH 072/128] Disable make cover if no gcov was found.

---
 Makefile.in |  4 ++++
 configure   | 14 ++++++++------
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index e6edd0d6e..5da4ace7a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -121,9 +121,13 @@ infcover: infcover.o libz.a
 	$(CC) $(CFLAGS) -coverage -o $@ infcover.o libz.a
 
 cover: infcover
+ifdef $(GCOV)
 	rm -f *.gcda
 	${QEMU_RUN} ./infcover
 	${GCOV} ${LLVM_GCOV_FLAG} inf*.c -o ./infcover.gcda
+else
+	@echo 'cover disabled as no suitable gcov was found'
+endif
 
 libz.a: $(OBJS)
 	$(AR) $(ARFLAGS) $@ $(OBJS)
diff --git a/configure b/configure
index 03a9e78bc..393c23c94 100755
--- a/configure
+++ b/configure
@@ -200,25 +200,27 @@ esac
 
 if test "$clang" -eq 1; then
   if test "$cc" = "clang"; then
-    if `llvm-cov --version > /dev/null`; then
-      GCOV="llvm-cov-${clangV}"
+    if which -s llvm-cov; then
+      GCOV="llvm-cov"
+      LLVM_GCOV_FLAG="gcov"
+      GCOV="llvm-cov"
       LLVM_GCOV_FLAG="gcov"
+      echo "Using ${GCOV} for coverage"
     else
       cover=0
+      GCOV=""
       LLVM_GCOV_FLAG=""
       echo "Deactivating cover as no suitable gcov can be found"
     fi
-    GCOV="llvm-cov"
-    LLVM_GCOV_FLAG="gcov"
-    echo "Using ${GCOV} for coverage"
   else
     clangV=`echo "$cc" | sed -e 's/^.*-//'`
-    if `llvm-cov-${clangV} --version > /dev/null`; then
+    if which -s llvm-cov-${clangV}; then
       GCOV="llvm-cov-${clangV}"
       LLVM_GCOV_FLAG="gcov"
       echo "Using ${GCOV} for coverage"
     else
       cover=0
+      GCOV=""
       LLVM_GCOV_FLAG=""
       echo "Deactivating cover as no suitable gcov can be found"
     fi

From 9d25fa340ef7dc35606ea3373b090e9d4e8267b9 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Thu, 26 Dec 2024 14:02:31 +0100
Subject: [PATCH 073/128] Use consistent comment style in minizip.

---
 contrib/minizip/ioapi.c   |   2 +-
 contrib/minizip/ioapi.h   |   8 +-
 contrib/minizip/minizip.c |   2 +-
 contrib/minizip/mztools.c |   2 +-
 contrib/minizip/skipset.h | 144 ++++++++++++-------------
 contrib/minizip/unzip.c   |  16 +--
 contrib/minizip/zip.c     | 218 +++++++++++++++++++-------------------
 contrib/minizip/zip.h     |   2 +-
 8 files changed, 197 insertions(+), 197 deletions(-)

diff --git a/contrib/minizip/ioapi.c b/contrib/minizip/ioapi.c
index 782d32469..3dbefe48c 100644
--- a/contrib/minizip/ioapi.c
+++ b/contrib/minizip/ioapi.c
@@ -15,7 +15,7 @@
 #endif
 
 #if defined(__APPLE__) || defined(IOAPI_NO_64) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
-// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
+/* In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions */
 #define FOPEN_FUNC(filename, mode) fopen(filename, mode)
 #define FTELLO_FUNC(stream) ftello(stream)
 #define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin)
diff --git a/contrib/minizip/ioapi.h b/contrib/minizip/ioapi.h
index f3b193d80..6b9968c73 100644
--- a/contrib/minizip/ioapi.h
+++ b/contrib/minizip/ioapi.h
@@ -23,8 +23,8 @@
 
 #if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
 
-  // Linux needs this to support file operation on files larger then 4+GB
-  // But might need better if/def to select just the platforms that needs them.
+  /* Linux needs this to support file operation on files larger then 4+GB */
+  /* But might need better if/def to select just the platforms that needs them.*/
 
         #ifndef __USE_FILE_OFFSET64
                 #define __USE_FILE_OFFSET64
@@ -161,8 +161,8 @@ typedef struct zlib_filefunc64_32_def_s
 
 #define ZREAD64(filefunc,filestream,buf,size)     ((*((filefunc).zfile_func64.zread_file))   ((filefunc).zfile_func64.opaque,filestream,buf,size))
 #define ZWRITE64(filefunc,filestream,buf,size)    ((*((filefunc).zfile_func64.zwrite_file))  ((filefunc).zfile_func64.opaque,filestream,buf,size))
-//#define ZTELL64(filefunc,filestream)            ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))
-//#define ZSEEK64(filefunc,filestream,pos,mode)   ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))
+/*#define ZTELL64(filefunc,filestream)            ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream)) */
+/*#define ZSEEK64(filefunc,filestream,pos,mode)   ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode)) */
 #define ZCLOSE64(filefunc,filestream)             ((*((filefunc).zfile_func64.zclose_file))  ((filefunc).zfile_func64.opaque,filestream))
 #define ZERROR64(filefunc,filestream)             ((*((filefunc).zfile_func64.zerror_file))  ((filefunc).zfile_func64.opaque,filestream))
 
diff --git a/contrib/minizip/minizip.c b/contrib/minizip/minizip.c
index a44e36a01..18d866b6f 100644
--- a/contrib/minizip/minizip.c
+++ b/contrib/minizip/minizip.c
@@ -435,7 +435,7 @@ int main(int argc, char *argv[]) {
                      }
                      if( lastslash != NULL )
                      {
-                         savefilenameinzip = lastslash+1; // base filename follows last slash.
+                         savefilenameinzip = lastslash+1; /* base filename follows last slash. */
                      }
                  }
 
diff --git a/contrib/minizip/mztools.c b/contrib/minizip/mztools.c
index f86c1e71b..6260cb0ed 100644
--- a/contrib/minizip/mztools.c
+++ b/contrib/minizip/mztools.c
@@ -219,7 +219,7 @@ extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char*
     {
       int entriesZip = entries;
       char end[22];
-      char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools";
+      char* comment = ""; /* "ZIP File recovered by zlib/minizip/mztools"; */
       int comsize = (int) strlen(comment);
       if (entriesZip > 0xffff) {
         entriesZip = 0xffff;
diff --git a/contrib/minizip/skipset.h b/contrib/minizip/skipset.h
index 5e648b9d2..9f0aad612 100644
--- a/contrib/minizip/skipset.h
+++ b/contrib/minizip/skipset.h
@@ -1,4 +1,4 @@
-// skipset.h -- set operations using a skiplist
+/* skipset.h -- set operations using a skiplist
 // Copyright (C) 2024 Mark Adler
 // See MiniZip_info.txt for the license.
 
@@ -50,20 +50,20 @@
 // Auxiliary functions available to the application:
 // - set_alloc() allocates memory with optional tracking (#define SET_TRACK)
 // - set_free() deallocates memory allocated by set_alloc()
-// - set_rand() returns 32 random bits (seeded by set_start())
+// - set_rand() returns 32 random bits (seeded by set_start()) */
 
 #ifndef SKIPSET_H
 #define SKIPSET_H
 
-#include <stdlib.h>     // realloc(), free(), NULL, size_t
-#include <stddef.h>     // ptrdiff_t
-#include <setjmp.h>     // jmp_buf, longjmp()
-#include <errno.h>      // ENOMEM
-#include <time.h>       // time(), clock()
-#include <assert.h>     // assert.h
-#include "ints.h"       // i16_t, ui32_t, ui64_t
+#include <stdlib.h>     /* realloc(), free(), NULL, size_t */
+#include <stddef.h>     /* ptrdiff_t */
+#include <setjmp.h>     /* jmp_buf, longjmp() */
+#include <errno.h>      /* ENOMEM */
+#include <time.h>       /* time(), clock() */
+#include <assert.h>     /* assert.h */
+#include "ints.h"       /* i16_t, ui32_t, ui64_t */
 
-// Structures and functions below noted as "--private--" should not be used by
+/* Structures and functions below noted as "--private--" should not be used by
 // the application. set_t is partially private and partially public -- see the
 // comments there.
 
@@ -73,18 +73,18 @@
 
 // *Really* minimal PCG32 code / (c) 2014 M.E. O'Neill / www.pcg-random.org
 // Licensed under Apache License 2.0 (NO WARRANTY, etc. see website)
-// --private-- Random number generator state.
+// --private-- Random number generator state. */
 typedef struct {
-    ui64_t state;       // 64-bit generator state
-    ui64_t inc;         // 63-bit sequence id
+    ui64_t state;       /* 64-bit generator state */
+    ui64_t inc;         /* 63-bit sequence id */
 } set_rand_t;
-// --private-- Initialize the state *gen using seed and seq. seed seeds the
-// advancing 64-bit state. seq is a sequence selection constant.
+/* --private-- Initialize the state *gen using seed and seq. seed seeds the
+// advancing 64-bit state. seq is a sequence selection constant. */
 void set_seed(set_rand_t *gen, ui64_t seed, ui64_t seq) {
     gen->inc = (seq << 1) | 1;
     gen->state = (seed + gen->inc) * 6364136223846793005ULL + gen->inc;
 }
-// Return 32 random bits, advancing the state *gen.
+/* Return 32 random bits, advancing the state *gen. */
 ui32_t set_rand(set_rand_t *gen) {
     ui64_t state = gen->state;
     gen->state = state * 6364136223846793005ULL + gen->inc;
@@ -92,40 +92,40 @@ ui32_t set_rand(set_rand_t *gen) {
     int rot = state >> 59;
     return (mix >> rot) | (mix << ((-rot) & 31));
 }
-// End of PCG32 code.
+/* End of PCG32 code. */
 
-// --private-- Linked-list node.
+/* --private-- Linked-list node. */
 typedef struct set_node_s set_node_t;
 struct set_node_s {
-    set_key_t key;          // the key (not used for head or path)
-    i16_t size;             // number of allocated pointers in right[]
-    i16_t fill;             // number of pointers in right[] filled in
-    set_node_t **right;     // pointer for each level, each to the right
+    set_key_t key;          /* the key (not used for head or path) */
+    i16_t size;             /* number of allocated pointers in right[] */
+    i16_t fill;             /* number of pointers in right[] filled in */
+    set_node_t **right;     /* pointer for each level, each to the right */
 };
 
-// A set. The application sets env, may use gen with set_rand(), and may read
-// allocs and memory. The remaining variables are --private-- .
+/* A set. The application sets env, may use gen with set_rand(), and may read
+// allocs and memory. The remaining variables are --private-- . */
 typedef struct set_s {
-    set_node_t *head;       // skiplist head -- no key, just links
-    set_node_t *path;       // right[] is path to key from set_found()
-    set_node_t *node;       // node under construction, in case of longjmp()
-    i16_t depth;            // maximum depth of the skiplist
-    ui64_t ran;             // a precious trove of random bits
-    set_rand_t gen;         // random number generator state
-    jmp_buf env;            // setjmp() environment for allocation errors
+    set_node_t *head;       /* skiplist head -- no key, just links */
+    set_node_t *path;       /* right[] is path to key from set_found() */
+    set_node_t *node;       /* node under construction, in case of longjmp() */
+    i16_t depth;            /* maximum depth of the skiplist */
+    ui64_t ran;             /* a precious trove of random bits */
+    set_rand_t gen;         /* random number generator state */
+    jmp_buf env;            /* setjmp() environment for allocation errors */
 #ifdef SET_TRACK
-    size_t allocs;          // number of allocations
-    size_t memory;          // total amount of allocated memory (>= requests)
+    size_t allocs;          /* number of allocations */
+    size_t memory;          /* total amount of allocated memory (>= requests) */
 #endif
 } set_t;
 
-// Memory allocation and deallocation. set_alloc(set, ptr, size) returns a
+/* Memory allocation and deallocation. set_alloc(set, ptr, size) returns a
 // pointer to an allocation of size bytes if ptr is NULL, or the previous
 // allocation ptr resized to size bytes. set_alloc() will never return NULL.
 // set_free(set, ptr) frees an allocation created by set_alloc(). These may be
-// used by the application. e.g. if allocation tracking is desired.
+// used by the application. e.g. if allocation tracking is desired. */
 #ifdef SET_TRACK
-// Track the number of allocations and the total backing memory size.
+/* Track the number of allocations and the total backing memory size. */
 #  if defined(_WIN32)
 #    include <malloc.h>
 #    define SET_ALLOC_SIZE(ptr) _msize(ptr)
@@ -162,7 +162,7 @@ void set_free(set_t *set, void *ptr) {
     }
 }
 #else
-// Without tracking.
+/* Without tracking. */
 void *set_alloc(set_t *set, void *ptr, size_t size) {
     void *mem = realloc(ptr, size);
     if (mem == NULL)
@@ -175,10 +175,10 @@ void set_free(set_t *set, void *ptr) {
 }
 #endif
 
-// --private-- Grow node's array right[] as needed to be able to hold at least
+/* --private-- Grow node's array right[] as needed to be able to hold at least
 // want links. If fill is true, assure that the first want links are filled in,
 // setting them to set->head if not previously filled in. Otherwise it is
-// assumed that the first want links are about to be filled in.
+// assumed that the first want links are about to be filled in. */
 void set_grow(set_t *set, set_node_t *node, int want, int fill) {
     if (node->size < want) {
         int more = node->size ? node->size : 1;
@@ -194,7 +194,7 @@ void set_grow(set_t *set, set_node_t *node, int want, int fill) {
     node->fill = (i16_t)want;
 }
 
-// --private-- Return a new node. key is left uninitialized.
+/* --private-- Return a new node. key is left uninitialized. */
 set_node_t *set_node(set_t *set) {
     set_node_t *node = set_alloc(set, NULL, sizeof(set_node_t));
     node->size = 0;
@@ -203,11 +203,11 @@ set_node_t *set_node(set_t *set) {
     return node;
 }
 
-// --private-- Free the list linked from head, along with the keys.
+/* --private-- Free the list linked from head, along with the keys. */
 void set_sweep(set_t *set) {
     set_node_t *step = set->head->right[0];
     while (step != set->head) {
-        set_node_t *next = step->right[0];      // save link to next node
+        set_node_t *next = step->right[0];      /* save link to next node */
         set_drop(set, step->key);
         set_free(set, step->right);
         set_free(set, step);
@@ -215,59 +215,59 @@ void set_sweep(set_t *set) {
     }
 }
 
-// Initialize a new set. set->env must be initialized using setjmp() before
+/* Initialize a new set. set->env must be initialized using setjmp() before
 // set_start() is called. A longjmp(set->env, ENOMEM) will be used to handle a
 // memory allocation failure during any of the operations. (See setjmp.h and
 // errno.h.) The set can still be used if this happens, assuming that it didn't
 // happen during set_start(). Whether set_start() completed or not, set_end()
-// can be used to free the set's memory after a longjmp().
+// can be used to free the set's memory after a longjmp(). */
 void set_start(set_t *set) {
 #ifdef SET_TRACK
     set->allocs = 0;
     set->memory = 0;
 #endif
-    set->head = set->path = set->node = NULL;   // in case set_node() fails
+    set->head = set->path = set->node = NULL;   /* in case set_node() fails */
     set->path = set_node(set);
     set->head = set_node(set);
-    set_grow(set, set->head, 1, 1); // one link back to head for an empty set
-    *(unsigned char *)&set->head->key = 137;    // set id
+    set_grow(set, set->head, 1, 1); /* one link back to head for an empty set */
+    *(unsigned char *)&set->head->key = 137;    /* set id */
     set->depth = 0;
     set_seed(&set->gen, ((ui64_t)(ptrdiff_t)set << 32) ^
                         ((ui64_t)time(NULL) << 12) ^ clock(), 0);
     set->ran = 1;
 }
 
-// Return true if *set appears to be in a usable state. If *set has been zeroed
-// out, then set_ok(set) will be false and set_end(set) will be safe.
+/* Return true if *set appears to be in a usable state. If *set has been zeroed
+// out, then set_ok(set) will be false and set_end(set) will be safe. */
 int set_ok(set_t *set) {
     return set->head != NULL &&
            set->head->right != NULL &&
            *(unsigned char *)&set->head->key == 137;
 }
 
-// Empty the set. This frees the memory used for the previous set contents.
-// After set_clear(), *set is ready for use, as if after a set_start().
+/* Empty the set. This frees the memory used for the previous set contents.
+// After set_clear(), *set is ready for use, as if after a set_start(). */
 void set_clear(set_t *set) {
     assert(set_ok(set) && "improper use");
 
-    // Free all the keys and their nodes.
+    /* Free all the keys and their nodes. */
     set_sweep(set);
 
-    // Leave the head and path allocations as is. Clear their contents, with
-    // head pointing to itself and setting depth to zero, for an empty set.
+    /* Leave the head and path allocations as is. Clear their contents, with
+    // head pointing to itself and setting depth to zero, for an empty set. */
     set->head->right[0] = set->head;
     set->head->fill = 1;
     set->path->fill = 0;
     set->depth = 0;
 }
 
-// Done using the set -- free all allocations. The only operation on *set
+/* Done using the set -- free all allocations. The only operation on *set
 // permitted after this is set_start(). Though another set_end() would do no
 // harm. This can be done at any time after a set_start(), or after a longjmp()
-// on any allocation failure, including during a set_start().
+// on any allocation failure, including during a set_start(). */
 void set_end(set_t *set) {
     if (set->head != NULL) {
-        // Empty the set and free the head node.
+        /* Empty the set and free the head node. */
         if (set->head->right != NULL) {
             set_sweep(set);
             set_free(set, set->head->right);
@@ -276,13 +276,13 @@ void set_end(set_t *set) {
         set->head = NULL;
     }
     if (set->path != NULL) {
-        // Free the path work area.
+        /* Free the path work area. */
         set_free(set, set->path->right);
         set_free(set, set->path);
         set->path = NULL;
     }
     if (set->node != NULL) {
-        // Free the node that was under construction when longjmp() hit.
+        /* Free the node that was under construction when longjmp() hit. */
         set_drop(set, set->node->key);
         set_free(set, set->node->right);
         set_free(set, set->node);
@@ -290,12 +290,12 @@ void set_end(set_t *set) {
     }
 }
 
-// Look for key. Return 1 if found or 0 if not. This also puts the path to get
-// there in set->path, for use by set_insert().
+/* Look for key. Return 1 if found or 0 if not. This also puts the path to get
+// there in set->path, for use by set_insert(). */
 int set_found(set_t *set, set_key_t key) {
     assert(set_ok(set) && "improper use");
 
-    // Start at depth and work down and right as determined by key comparisons.
+    /* Start at depth and work down and right as determined by key comparisons. */
     set_node_t *head = set->head, *here = head;
     int i = set->depth;
     set_grow(set, set->path, i + 1, 0);
@@ -306,25 +306,25 @@ int set_found(set_t *set, set_key_t key) {
         set->path->right[i] = here;
     } while (i--);
 
-    // See if the key matches.
+    /* See if the key matches. */
     here = here->right[0];
     return here != head && set_cmp(here->key, key) == 0;
 }
 
-// Insert the key key. Return 0 on success, or 1 if key is already in the set.
+/* Insert the key key. Return 0 on success, or 1 if key is already in the set. */
 int set_insert(set_t *set, set_key_t key) {
     assert(set_ok(set) && "improper use");
 
     if (set_found(set, key))
-        // That key is already in the set.
+        /* That key is already in the set. */
         return 1;
 
-    // Randomly generate a new level-- level 0 with probability 1/2, 1 with
-    // probability 1/4, 2 with probability 1/8, etc.
+    /* Randomly generate a new level-- level 0 with probability 1/2, 1 with
+    // probability 1/4, 2 with probability 1/8, etc. */
     int level = 0;
     for (;;) {
         if (set->ran == 1)
-            // Ran out. Get another 32 random bits.
+            /* Ran out. Get another 32 random bits. */
             set->ran = set_rand(&set->gen) | (1ULL << 32);
         int bit = set->ran & 1;
         set->ran >>= 1;
@@ -335,14 +335,14 @@ int set_insert(set_t *set, set_key_t key) {
         level++;
     }
     if (level > set->depth) {
-        // The maximum depth is now deeper. Update the structures.
+        /* The maximum depth is now deeper. Update the structures. */
         set_grow(set, set->path, level + 1, 1);
         set_grow(set, set->head, level + 1, 1);
         set->depth = (i16_t)level;
     }
 
-    // Make a new node for the provided key, and insert it in the lists up to
-    // and including level.
+    /* Make a new node for the provided key, and insert it in the lists up to
+    // and including level. */
     set->node = set_node(set);
     set->node->key = key;
     set_grow(set, set->node, level + 1, 0);
@@ -357,5 +357,5 @@ int set_insert(set_t *set, set_key_t key) {
 
 #else
 #error ** another skiplist set already created here
-// Would need to implement a prefix in order to support multiple sets.
+/* Would need to implement a prefix in order to support multiple sets. */
 #endif
diff --git a/contrib/minizip/unzip.c b/contrib/minizip/unzip.c
index a2ee14bdd..e9088bd54 100644
--- a/contrib/minizip/unzip.c
+++ b/contrib/minizip/unzip.c
@@ -842,7 +842,7 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file,
     if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK)
         err=UNZ_ERRNO;
 
-                // relative offset of local header
+                /* relative offset of local header */
     if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
         err=UNZ_ERRNO;
     file_info_internal.offset_curfile = uL;
@@ -865,7 +865,7 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file,
         lSeek -= uSizeRead;
     }
 
-    // Read extrafield
+    /* Read extrafield */
     if ((err==UNZ_OK) && (extraField!=NULL))
     {
         ZPOS64_T uSizeRead ;
@@ -896,7 +896,7 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file,
     {
                                 uLong acc = 0;
 
-        // since lSeek now points to after the extra field we need to move back
+        /* since lSeek now points to after the extra field we need to move back */
         lSeek -= file_info.size_file_extra;
 
         if (lSeek!=0)
@@ -1525,10 +1525,10 @@ extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file) {
     file_in_zip64_read_info_s* pfile_in_zip_read_info;
     s=(unz64_s*)file;
     if (file==NULL)
-        return 0; //UNZ_PARAMERROR;
+        return 0; /* UNZ_PARAMERROR; */
     pfile_in_zip_read_info=s->pfile_in_zip_read;
     if (pfile_in_zip_read_info==NULL)
-        return 0; //UNZ_PARAMERROR;
+        return 0; /* UNZ_PARAMERROR; */
     return pfile_in_zip_read_info->pos_in_zipfile +
                          pfile_in_zip_read_info->byte_before_the_zipfile;
 }
@@ -1697,7 +1697,7 @@ extern int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len) {
             if (err!=BZ_OK)
               break;
 #endif
-        } // end Z_BZIP2ED
+        } /* end Z_BZIP2ED */
         else
         {
             ZPOS64_T uTotalOutBefore,uTotalOutAfter;
@@ -1940,7 +1940,7 @@ extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file) {
     unz64_s* s;
 
     if (file==NULL)
-          return 0; //UNZ_PARAMERROR;
+          return 0; /* UNZ_PARAMERROR; */
     s=(unz64_s*)file;
     if (!s->current_file_ok)
       return 0;
@@ -1954,7 +1954,7 @@ extern uLong ZEXPORT unzGetOffset(unzFile file) {
     ZPOS64_T offset64;
 
     if (file==NULL)
-          return 0; //UNZ_PARAMERROR;
+          return 0; /* UNZ_PARAMERROR; */
     offset64 = unzGetOffset64(file);
     return (uLong)offset64;
 }
diff --git a/contrib/minizip/zip.c b/contrib/minizip/zip.c
index 93d2612e2..103f325d3 100644
--- a/contrib/minizip/zip.c
+++ b/contrib/minizip/zip.c
@@ -52,7 +52,7 @@
 #endif
 
 #ifndef Z_BUFSIZE
-#define Z_BUFSIZE (64*1024) //(16384)
+#define Z_BUFSIZE (64*1024) /* (16384) */
 #endif
 
 #ifndef Z_MAXFILENAMEINZIP
@@ -71,7 +71,7 @@
 /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
 
 
-// NOT sure that this work on ALL platform
+/* NOT sure that this work on ALL platform */
 #define MAKEULONG64(a, b) ((ZPOS64_T)(((unsigned long)(a)) | ((ZPOS64_T)((unsigned long)(b))) << 32))
 
 #ifndef SEEK_CUR
@@ -125,16 +125,16 @@ typedef struct linkedlist_data_s
 } linkedlist_data;
 
 
-// zipAlreadyThere() set functions for a set of zero-terminated strings, and
-// a block_t type for reading the central directory datablocks.
+/* zipAlreadyThere() set functions for a set of zero-terminated strings, and
+// a block_t type for reading the central directory datablocks. */
 typedef char *set_key_t;
 #define set_cmp(a, b) strcmp(a, b)
 #define set_drop(s, k) set_free(s, k)
 #include "skipset.h"
 typedef struct {
-    unsigned char *next;        // next byte in datablock data
-    size_t left;                // number of bytes left in data (at least)
-    linkedlist_datablock_internal *node;    // current datablock
+    unsigned char *next;        /* next byte in datablock data */
+    size_t left;                /* number of bytes left in data (at least) */
+    linkedlist_datablock_internal *node;    /* current datablock */
 } block_t;
 
 
@@ -189,9 +189,9 @@ typedef struct
     char *globalcomment;
 #endif
 
-    // Support for zipAlreadyThere().
-    set_t set;              // set for detecting name collisions
-    block_t block;          // block for reading the central directory
+    /* Support for zipAlreadyThere(). */
+    set_t set;              /* set for detecting name collisions */
+    block_t block;          /* block for reading the central directory */
 
 } zip64_internal;
 
@@ -283,7 +283,7 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len)
     return ZIP_OK;
 }
 
-// zipAlreadyThere() operations. "set" in the zip internal structure keeps the
+/* zipAlreadyThere() operations. "set" in the zip internal structure keeps the
 // set of names that are in the under-construction central directory so far. A
 // skipset provides ~O(log n) time insertion and searching. Central directory
 // records, stored in a linked list of allocated memory datablocks, is read
@@ -295,81 +295,81 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len)
 // datablocks.
 
 // Initialize *block to the head of list. This should only be called once the
-// list has at least some data in it, i.e. list->first_block is not NULL.
+// list has at least some data in it, i.e. list->first_block is not NULL. */
 local void block_init(block_t *block, linkedlist_data *list) {
     block->node = list->first_block;
     block->next = block->node->data;
     block->left = block->node->filled_in_this_block;
 }
 
-// Mark *block as bad, with all subsequent reads returning end, even if more
+/* Mark *block as bad, with all subsequent reads returning end, even if more
 // data is added to the datablocks. This is invoked if the central directory is
-// invalid, so there is no longer any point in attempting to interpret it.
+// invalid, so there is no longer any point in attempting to interpret it. */
 local void block_stop(block_t *block) {
     block->left = 0;
     block->next = NULL;
 }
 
-// Return true if *block has reached the end of the data in the datablocks.
+/* Return true if *block has reached the end of the data in the datablocks. */
 local int block_end(block_t *block) {
     linkedlist_datablock_internal *node = block->node;
     if (node == NULL)
-        // This block was previously terminated with extreme prejudice.
+        /* This block was previously terminated with extreme prejudice. */
         return 1;
     if (block->next < node->data + node->filled_in_this_block)
-        // There are more bytes to read in the current datablock.
+        /* There are more bytes to read in the current datablock. */
         return 0;
     while (node->next_datablock != NULL) {
         if (node->filled_in_this_block != 0)
-            // There are some bytes in a later datablock.
+            /* There are some bytes in a later datablock. */
             return 0;
         node = node->next_datablock;
     }
-    // Reached the end of the list of datablocks. There's nothing.
+    /* Reached the end of the list of datablocks. There's nothing. */
     return 1;
 }
 
-// Return one byte from *block, or -1 if the end is reached.
+/* Return one byte from *block, or -1 if the end is reached. */
 local int block_get(block_t *block) {
     while (block->left == 0) {
         if (block->node == NULL)
-            // We've been marked bad. Return end.
+            /* We've been marked bad. Return end. */
             return -1;
-        // Update left in case more was filled in since we were last here.
+        /* Update left in case more was filled in since we were last here. */
         block->left = block->node->filled_in_this_block -
                       (block->next - block->node->data);
         if (block->left != 0)
-            // There was indeed more data appended in the current datablock.
+            /* There was indeed more data appended in the current datablock. */
             break;
         if (block->node->next_datablock == NULL)
-            // No more data here, and there is no next datablock. At the end.
+            /* No more data here, and there is no next datablock. At the end. */
             return -1;
-        // Try the next datablock for more data.
+        /* Try the next datablock for more data. */
         block->node = block->node->next_datablock;
         block->next = block->node->data;
         block->left = block->node->filled_in_this_block;
     }
-    // We have a byte to return.
+    /* We have a byte to return. */
     block->left--;
     return *block->next++;
 }
 
-// Return a 16-bit unsigned little-endian value from block, or a negative value
-// if the end is reached.
+/* Return a 16-bit unsigned little-endian value from block, or a negative value
+// if the end is reached. */
 local long block_get2(block_t *block) {
     long got = block_get(block);
     return got | ((unsigned long)block_get(block) << 8);
 }
 
-// Read up to len bytes from block into buf. Return the number of bytes read.
+/* Read up to len bytes from block into buf. Return the number of bytes read. */
 local size_t block_read(block_t *block, unsigned char *buf, size_t len) {
     size_t need = len;
     while (need) {
         if (block->left == 0) {
-            // Get a byte to update and step through the linked list as needed.
+            /* Get a byte to update and step through the linked list as needed. */
             int got = block_get(block);
             if (got == -1)
-                // Reached the end.
+                /* Reached the end. */
                 break;
             *buf++ = (unsigned char)got;
             need--;
@@ -382,11 +382,11 @@ local size_t block_read(block_t *block, unsigned char *buf, size_t len) {
         buf += take;
         need -= take;
     }
-    return len - need;      // return the number of bytes copied
+    return len - need;      /* return the number of bytes copied */
 }
 
-// Skip n bytes in block. Return 0 on success or -1 if there are less than n
-// bytes to the end.
+/* Skip n bytes in block. Return 0 on success or -1 if there are less than n
+// bytes to the end. */
 local int block_skip(block_t *block, size_t n) {
     while (n > block->left) {
         n -= block->left;
@@ -401,103 +401,103 @@ local int block_skip(block_t *block, size_t n) {
     return 0;
 }
 
-// Process the next central directory record at *block. Return the allocated,
+/* Process the next central directory record at *block. Return the allocated,
 // zero-terminated file name, or NULL for end of input or invalid data. If
-// invalid, *block is marked bad. This uses *set for the allocation of memory.
+// invalid, *block is marked bad. This uses *set for the allocation of memory. */
 local char *block_central_name(block_t *block, set_t *set) {
     char *name = NULL;
     for (;;) {
         if (block_end(block))
-            // At the end of the central directory (so far).
+            /* At the end of the central directory (so far). */
             return NULL;
 
-        // Check for a central directory record signature.
+        /* Check for a central directory record signature. */
         if (block_get2(block) != (CENTRALHEADERMAGIC & 0xffff) ||
             block_get2(block) != (CENTRALHEADERMAGIC >> 16))
-            // Incorrect signature.
+            /* Incorrect signature. */
             break;
 
-        // Go through the remaining fixed-length portion of the record,
-        // extracting the lengths of the three variable-length fields.
+        /* Go through the remaining fixed-length portion of the record,
+        // extracting the lengths of the three variable-length fields. */
         block_skip(block, 24);
-        unsigned flen = block_get2(block);      // file name length
-        unsigned xlen = block_get2(block);      // extra field length
-        unsigned clen = block_get2(block);      // comment field length
+        unsigned flen = block_get2(block);      /* file name length */
+        unsigned xlen = block_get2(block);      /* extra field length */
+        unsigned clen = block_get2(block);      /* comment field length */
         if (block_skip(block, 12) == -1)
-            // Premature end of the record.
+            /* Premature end of the record. */
             break;
 
-        // Extract the name and skip over the extra and comment fields.
+        /* Extract the name and skip over the extra and comment fields. */
         name = set_alloc(set, NULL, flen + 1);
         if (block_read(block, (unsigned char *)name, flen) < flen ||
             block_skip(block, xlen + clen) == -1)
-            // Premature end of the record.
+            /* Premature end of the record. */
             break;
 
-        // Check for embedded nuls in the name.
+        /* Check for embedded nuls in the name. */
         if (memchr(name, 0, flen) != NULL) {
-            // This name can never match the zero-terminated name provided to
+            /* This name can never match the zero-terminated name provided to
             // zipAlreadyThere(), so we discard it and go back to get another
             // name. (Who the heck is putting nuls inside their zip file entry
-            // names anyway?)
+            // names anyway?) */
             set_free(set, name);
             continue;
         }
 
-        // All good. Return the zero-terminated file name.
+        /* All good. Return the zero-terminated file name. */
         name[flen] = 0;
         return name;
     }
 
-    // Invalid signature or premature end of the central directory record.
-    // Abandon trying to process the central directory.
+    /* Invalid signature or premature end of the central directory record.
+    // Abandon trying to process the central directory. */
     set_free(set, name);
     block_stop(block);
     return NULL;
 }
 
-// Return 0 if name is not in the central directory so far, 1 if it is, -1 if
+/* Return 0 if name is not in the central directory so far, 1 if it is, -1 if
 // the central directory is invalid, -2 if out of memory, or ZIP_PARAMERROR if
-// file is NULL.
+// file is NULL. */
 extern int ZEXPORT zipAlreadyThere(zipFile file, char const *name) {
     zip64_internal *zip = file;
     if (zip == NULL)
         return ZIP_PARAMERROR;
     if (zip->central_dir.first_block == NULL)
-        // No central directory yet, so no, name isn't there.
+        /* No central directory yet, so no, name isn't there. */
         return 0;
     if (setjmp(zip->set.env)) {
-        // Memory allocation failure.
+        /* Memory allocation failure. */
         set_end(&zip->set);
         return -2;
     }
     if (!set_ok(&zip->set)) {
-        // This is the first time here with some central directory content. We
-        // construct this set of names only on demand. Prepare set and block.
+        /* This is the first time here with some central directory content. We
+        // construct this set of names only on demand. Prepare set and block. */
         set_start(&zip->set);
         block_init(&zip->block, &zip->central_dir);
     }
 
-    // Update the set of names from the current central directory contents.
+    /* Update the set of names from the current central directory contents.
     // This reads any new central directory records since the last time we were
-    // here.
+    // here. */
     for (;;) {
         char *there = block_central_name(&zip->block, &zip->set);
         if (there == NULL) {
             if (zip->block.next == NULL)
-                // The central directory is invalid.
+                /* The central directory is invalid. */
                 return -1;
             break;
         }
 
-        // Add there to the set.
+        /* Add there to the set. */
         if (set_insert(&zip->set, there))
-            // There's already a duplicate in the central directory! We'll just
-            // let this be and carry on.
+            /* There's already a duplicate in the central directory! We'll just
+            // let this be and carry on. */
             set_free(&zip->set, there);
     }
 
-    // Return true if name is in the central directory.
+    /* Return true if name is in the central directory. */
     size_t len = strlen(name);
     char *copy = set_alloc(&zip->set, NULL, len + 1);
     strcpy(copy, name);
@@ -792,7 +792,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
 
     for (i=(int)uReadSize-3; (i--)>0;)
     {
-      // Signature "0x07064b50" Zip64 end of central directory locator
+      /* Signature "0x07064b50" Zip64 end of central directory locator */
       if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
       {
         uPosFound = uReadPos+(unsigned)i;
@@ -840,7 +840,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
   if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK)
     return 0;
 
-  if (uL != 0x06064b50) // signature of 'Zip64 end of central directory'
+  if (uL != 0x06064b50) /* signature of 'Zip64 end of central directory' */
     return 0;
 
   return relativeOffset;
@@ -869,7 +869,7 @@ local int LoadCentralDirectoryRecord(zip64_internal* pziinit) {
 
   int hasZIP64Record = 0;
 
-  // check first if we find a ZIP64 record
+  /* check first if we find a ZIP64 record */
   central_pos = zip64local_SearchCentralDir64(&pziinit->z_filefunc,pziinit->filestream);
   if(central_pos > 0)
   {
@@ -935,13 +935,13 @@ local int LoadCentralDirectoryRecord(zip64_internal* pziinit) {
     if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream,&offset_central_dir)!=ZIP_OK)
       err=ZIP_ERRNO;
 
-    // TODO..
-    // read the comment from the standard central header.
+    /* TODO..
+    // read the comment from the standard central header. */
     size_comment = 0;
   }
   else
   {
-    // Read End of central Directory info
+    /* Read End of central Directory info */
     if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
       err=ZIP_ERRNO;
 
@@ -1084,7 +1084,7 @@ extern zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc* glo
     ziinit.number_entry = 0;
     ziinit.add_position_when_writing_offset = 0;
     init_linkedlist(&(ziinit.central_dir));
-    memset(&ziinit.set, 0, sizeof(set_t));  // make sure set appears dormant
+    memset(&ziinit.set, 0, sizeof(set_t));  /* make sure set appears dormant */
 
 
 
@@ -1100,7 +1100,7 @@ extern zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc* glo
     ziinit.globalcomment = NULL;
     if (append == APPEND_STATUS_ADDINZIP)
     {
-      // Read and Cache Central Directory Records
+      /* Read and Cache Central Directory Records */
       err = LoadCentralDirectoryRecord(&ziinit);
     }
 
@@ -1184,7 +1184,7 @@ local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt s
   if (err==ZIP_OK)
     err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.dosDate,4);
 
-  // CRC / Compressed size / Uncompressed size will be filled in later and rewritten later
+  /* CRC / Compressed size / Uncompressed size will be filled in later and rewritten later */
   if (err==ZIP_OK)
     err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* crc 32, unknown */
   if (err==ZIP_OK)
@@ -1228,13 +1228,13 @@ local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt s
 
   if ((err==ZIP_OK) && (zi->ci.zip64))
   {
-      // write the Zip64 extended info
+      /* write the Zip64 extended info */
       short HeaderID = 1;
       short DataSize = 16;
       ZPOS64_T CompressedSize = 0;
       ZPOS64_T UncompressedSize = 0;
 
-      // Remember position of Zip64 extended info for the local file header. (needed when we update size after done with file)
+      /* Remember position of Zip64 extended info for the local file header. (needed when we update size after done with file) */
       zi->ci.pos_zip64extrainfo = ZTELL64(zi->z_filefunc,zi->filestream);
 
       err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)HeaderID,2);
@@ -1284,14 +1284,14 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c
       return ZIP_PARAMERROR;
 #endif
 
-    // The filename and comment length must fit in 16 bits.
+    /* The filename and comment length must fit in 16 bits. */
     if ((filename!=NULL) && (strlen(filename)>0xffff))
         return ZIP_PARAMERROR;
     if ((comment!=NULL) && (strlen(comment)>0xffff))
         return ZIP_PARAMERROR;
-    // The extra field length must fit in 16 bits. If the member also requires
+    /* The extra field length must fit in 16 bits. If the member also requires
     // a Zip64 extra block, that will also need to fit within that 16-bit
-    // length, but that will be checked for later.
+    // length, but that will be checked for later. */
     if ((size_extrafield_local>0xffff) || (size_extrafield_global>0xffff))
         return ZIP_PARAMERROR;
 
@@ -1343,7 +1343,7 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c
     zi->ci.pos_local_header = ZTELL64(zi->z_filefunc,zi->filestream);
 
     zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + size_extrafield_global + size_comment;
-    zi->ci.size_centralExtraFree = 32; // Extra space we have reserved in case we need to add ZIP64 extra info data
+    zi->ci.size_centralExtraFree = 32; /* Extra space we have reserved in case we need to add ZIP64 extra info data */
 
     zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader + zi->ci.size_centralExtraFree);
 
@@ -1438,7 +1438,7 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c
         else if(zi->ci.method == Z_BZIP2ED)
         {
 #ifdef HAVE_BZIP2
-            // Init BZip stuff here
+            /* Init BZip stuff here */
           zi->ci.bstream.bzalloc = 0;
           zi->ci.bstream.bzfree = 0;
           zi->ci.bstream.opaque = (voidpf)0;
@@ -1640,7 +1640,7 @@ extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void* buf, unsigned i
         if ((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw))
         {
           uLong uTotalOutBefore_lo = zi->ci.bstream.total_out_lo32;
-//          uLong uTotalOutBefore_hi = zi->ci.bstream.total_out_hi32;
+/*          uLong uTotalOutBefore_hi = zi->ci.bstream.total_out_hi32; */
           err=BZ2_bzCompress(&zi->ci.bstream,  BZ_RUN);
 
           zi->ci.pos_in_buffered_data += (uInt)(zi->ci.bstream.total_out_lo32 - uTotalOutBefore_lo) ;
@@ -1698,7 +1698,7 @@ extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void* buf, unsigned i
                   zi->ci.pos_in_buffered_data += copy_this;
               }
           }
-      }// while(...)
+      }/* while(...) */
     }
 
     return err;
@@ -1804,7 +1804,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
     compressed_size += zi->ci.crypt_header_size;
 #    endif
 
-    // update Current Item crc and sizes,
+    /* update Current Item crc and sizes, */
     if(compressed_size >= 0xffffffff || uncompressed_size >= 0xffffffff || zi->ci.pos_local_header >= 0xffffffff)
     {
       /*version Made by*/
@@ -1822,7 +1822,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
     else
       zip64local_putValue_inmemory(zi->ci.central_header+20, compressed_size,4); /*compr size*/
 
-    /// set internal file attributes field
+    /* set internal file attributes field */
     if (zi->ci.stream.data_type == Z_ASCII)
         zip64local_putValue_inmemory(zi->ci.central_header+36,(uLong)Z_ASCII,2);
 
@@ -1831,15 +1831,15 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
     else
       zip64local_putValue_inmemory(zi->ci.central_header+24, uncompressed_size,4); /*uncompr size*/
 
-    // Add ZIP64 extra info field for uncompressed size
+    /* Add ZIP64 extra info field for uncompressed size */
     if(uncompressed_size >= 0xffffffff)
       datasize += 8;
 
-    // Add ZIP64 extra info field for compressed size
+    /* Add ZIP64 extra info field for compressed size */
     if(compressed_size >= 0xffffffff)
       datasize += 8;
 
-    // Add ZIP64 extra info field for relative offset to local file header of current file
+    /* Add ZIP64 extra info field for relative offset to local file header of current file */
     if(zi->ci.pos_local_header >= 0xffffffff)
       datasize += 8;
 
@@ -1849,16 +1849,16 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
 
       if((uLong)(datasize + 4) > zi->ci.size_centralExtraFree)
       {
-        // we cannot write more data to the buffer that we have room for.
+        /* we cannot write more data to the buffer that we have room for. */
         return ZIP_BADZIPFILE;
       }
 
       p = zi->ci.central_header + zi->ci.size_centralheader;
 
-      // Add Extra Information Header for 'ZIP64 information'
-      zip64local_putValue_inmemory(p, 0x0001, 2); // HeaderID
+      /* Add Extra Information Header for 'ZIP64 information' */
+      zip64local_putValue_inmemory(p, 0x0001, 2); /* HeaderID */
       p += 2;
-      zip64local_putValue_inmemory(p, datasize, 2); // DataSize
+      zip64local_putValue_inmemory(p, datasize, 2); /* DataSize */
       p += 2;
 
       if(uncompressed_size >= 0xffffffff)
@@ -1879,13 +1879,13 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
         p += 8;
       }
 
-      // Update how much extra free space we got in the memory buffer
+      /* Update how much extra free space we got in the memory buffer
       // and increase the centralheader size so the new ZIP64 fields are included
-      // ( 4 below is the size of HeaderID and DataSize field )
+      // ( 4 below is the size of HeaderID and DataSize field ) */
       zi->ci.size_centralExtraFree -= datasize + 4;
       zi->ci.size_centralheader += datasize + 4;
 
-      // Update the extra info size field
+      /* Update the extra info size field */
       zi->ci.size_centralExtra += datasize + 4;
       zip64local_putValue_inmemory(zi->ci.central_header+30,(uLong)zi->ci.size_centralExtra,2);
     }
@@ -1897,7 +1897,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
 
     if (err==ZIP_OK)
     {
-        // Update the LocalFileHeader with the new values.
+        /* Update the LocalFileHeader with the new values. */
 
         ZPOS64_T cur_pos_inzip = ZTELL64(zi->z_filefunc,zi->filestream);
 
@@ -1911,7 +1911,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
         {
           if(zi->ci.pos_zip64extrainfo > 0)
           {
-            // Update the size in the ZIP64 extended field.
+            /* Update the size in the ZIP64 extended field. */
             if (ZSEEK64(zi->z_filefunc,zi->filestream, zi->ci.pos_zip64extrainfo + 4,ZLIB_FILEFUNC_SEEK_SET)!=0)
               err = ZIP_ERRNO;
 
@@ -1922,7 +1922,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
               err = zip64local_putValue(&zi->z_filefunc, zi->filestream, compressed_size, 8);
           }
           else
-              err = ZIP_BADZIPFILE; // Caller passed zip64 = 0, so no room for zip64 info -> fatal
+              err = ZIP_BADZIPFILE; /* Caller passed zip64 = 0, so no room for zip64 info -> fatal */
         }
         else
         {
@@ -1976,7 +1976,7 @@ local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_
   err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDHEADERMAGIC,4);
 
   if (err==ZIP_OK) /* size of this 'zip64 end of central directory' */
-    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(ZPOS64_T)Zip64DataSize,8); // why ZPOS64_T of this ?
+    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(ZPOS64_T)Zip64DataSize,8); /* why ZPOS64_T of this ? */
 
   if (err==ZIP_OK) /* version made by */
     err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2);
@@ -2023,7 +2023,7 @@ local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centr
   {
     {
       if(zi->number_entry >= 0xFFFF)
-        err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); // use value in ZIP64 record
+        err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); /* use value in ZIP64 record */
       else
         err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2);
     }
@@ -2032,7 +2032,7 @@ local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centr
   if (err==ZIP_OK) /* total number of entries in the central dir */
   {
     if(zi->number_entry >= 0xFFFF)
-      err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); // use value in ZIP64 record
+      err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); /* use value in ZIP64 record */
     else
       err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2);
   }
@@ -2112,7 +2112,7 @@ extern int ZEXPORT zipClose(zipFile file, const char* global_comment) {
     }
     free_linkedlist(&(zi->central_dir));
 
-    set_end(&zi->set);          // set was zeroed, so this is safe
+    set_end(&zi->set);          /* set was zeroed, so this is safe */
 
     pos = centraldir_pos_inzip - zi->add_position_when_writing_offset;
     if(pos >= 0xffffffff || zi->number_entry >= 0xFFFF)
@@ -2162,13 +2162,13 @@ extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHea
     header = *(short*)p;
     dataSize = *(((short*)p)+1);
 
-    if( header == sHeader ) // Header found.
+    if( header == sHeader ) /* Header found. */
     {
-      p += dataSize + 4; // skip it. do not copy to temp buffer
+      p += dataSize + 4; /* skip it. do not copy to temp buffer */
     }
     else
     {
-      // Extra Info block should not be removed, So copy it to the temp buffer.
+      /* Extra Info block should not be removed, So copy it to the temp buffer. */
       memcpy(pTmp, p, dataSize + 4);
       p += dataSize + 4;
       size += dataSize + 4;
@@ -2178,14 +2178,14 @@ extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHea
 
   if(size < *dataLen)
   {
-    // clean old extra info block.
+    /* clean old extra info block. */
     memset(pData,0, *dataLen);
 
-    // copy the new extra info block over the old
+    /* copy the new extra info block over the old */
     if(size > 0)
       memcpy(pData, pNewHeader, size);
 
-    // set the new extra info size
+    /* set the new extra info size */
     *dataLen = size;
 
     retVal = ZIP_OK;
diff --git a/contrib/minizip/zip.h b/contrib/minizip/zip.h
index 1f7f0b263..9526eacd1 100644
--- a/contrib/minizip/zip.h
+++ b/contrib/minizip/zip.h
@@ -44,7 +44,7 @@
 extern "C" {
 #endif
 
-//#define HAVE_BZIP2
+/* #define HAVE_BZIP2 */
 
 #ifndef _ZLIB_H
 #include "zlib.h"

From 0263e58ad483421b3515e8f24158981f2c5e05fc Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Thu, 26 Dec 2024 14:03:04 +0100
Subject: [PATCH 074/128] CMake: Prevent a 32-bit minizip build.

---
 contrib/minizip/CMakeLists.txt | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/contrib/minizip/CMakeLists.txt b/contrib/minizip/CMakeLists.txt
index e5999518e..766efb904 100644
--- a/contrib/minizip/CMakeLists.txt
+++ b/contrib/minizip/CMakeLists.txt
@@ -4,6 +4,11 @@ project(minizip
     VERSION 1.0.0
     LANGUAGES C)
 
+if(CMAKE_SIZEOF_VOID_P LESS 8)
+    message(WARNING "libminizip needs 64bit - stopping here")
+    return()
+endif(CMAKE_SIZEOF_VOID_P LESS 8)
+
 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)

From 09b21ebd334be6d060393032583a9055c0ee8b9e Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Thu, 26 Dec 2024 14:10:46 +0100
Subject: [PATCH 075/128] Correct one more comment style in minizip.

---
 contrib/minizip/iowin32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/minizip/iowin32.c b/contrib/minizip/iowin32.c
index 49f5ba1b1..65095663a 100644
--- a/contrib/minizip/iowin32.c
+++ b/contrib/minizip/iowin32.c
@@ -26,7 +26,7 @@
 #endif
 
 
-// see Include/shared/winapifamily.h in the Windows Kit
+/* see Include/shared/winapifamily.h in the Windows Kit */
 #if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API)))
 
 #if !defined(WINAPI_FAMILY_ONE_PARTITION)

From e573155946e71cd4fdfaaa3e3bd433d3cfe914b0 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Thu, 26 Dec 2024 18:21:26 +0100
Subject: [PATCH 076/128] CMake: Add CPack.

---
 CMakeLists.txt                 | 30 +++++++++++++++++++++++++++---
 contrib/minizip/CMakeLists.txt | 24 +++++++++++++++++++-----
 2 files changed, 46 insertions(+), 8 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b9b5b92da..9003fd5a8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,7 +2,21 @@ cmake_minimum_required(VERSION 3.10)
 
 project(zlib
     LANGUAGES C
-    VERSION 1.3.1.1)
+    VERSION 1.3.1.1
+    HOMEPAGE_URL "https://zlib.net/"
+    DESCRIPTION "a general-purpose lossless data-compression library")
+
+#============================================================================
+# CPack
+#============================================================================
+set(CPACK_PACKAGE_VENDOR "zlib-Project")
+set(CPACK_PACKAGE_DESCRIPTION_FILE ${zlib_SOURCE_DIR}/README)
+set(CPACK_RESOURCE_FILE_LICENSE ${zlib_SOURCE_DIR}/LICENSE)
+set(CPACK_RESOURCE_FILE_README ${zlib_SOURCE_DIR}/README)
+
+#============================================================================
+# configuration
+#============================================================================
 
 option(ZLIB_BUILD_TESTING "Enable Zlib Examples as tests" ON)
 option(ZLIB_BUILD_SHARED "Enable building zlib shared library" ON)
@@ -24,12 +38,12 @@ if(NOT DEFINED CMAKE_BUILD_TYPE AND NOT IS_MULTI)
     message(STATUS "No CMAKE_BUILD_TYPE set -- using Release")
     set(CMAKE_BUILD_TYPE Release)
 endif(NOT DEFINED CMAKE_BUILD_TYPE AND NOT IS_MULTI)
-
 include(CheckTypeSize)
 include(CheckFunctionExists)
 include(CheckIncludeFile)
 include(CheckCSourceCompiles)
 include(CMakePackageConfigHelpers)
+include(CPack)
 include(GNUInstallDirs)
 
 if(NOT ZLIB_CONF_WRITTEN)
@@ -275,8 +289,18 @@ if(ZLIB_INSTALL_LIBRARIES)
             COMPONENT Development
             DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
     install(FILES zlib.3
-            COMPONENT Development
+            COMPONENT Docs
             DESTINATION "${CMAKE_INSTALL_MANDIR}/man3")
+    install(FILES
+                LICENSE
+                doc/algorithm.txt
+                doc/crc-doc.1.0.pdf
+                doc/rfc1950.txt
+                doc/rfc1951.txt
+                doc/rfc1952.txt
+                doc/txtvsbin.txt
+            COMPONENT Docs
+            DESTINATION "${CMAKE_INSTALL_DOCDIR}/zlib")
     install(FILES ${ZLIB_PC}
             COMPONENT Development
             DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
diff --git a/contrib/minizip/CMakeLists.txt b/contrib/minizip/CMakeLists.txt
index 766efb904..39e0dcb50 100644
--- a/contrib/minizip/CMakeLists.txt
+++ b/contrib/minizip/CMakeLists.txt
@@ -2,13 +2,26 @@ cmake_minimum_required(VERSION 3.12)
 
 project(minizip
     VERSION 1.0.0
-    LANGUAGES C)
+    LANGUAGES C
+    DESCRIPTION "A library for creating zipfiles based in zlib"
+    HOMEPAGE_URL "https://www.winimage.com/zLibDll/minizip.html")
 
-if(CMAKE_SIZEOF_VOID_P LESS 8)
+if(CMAKE_SIZEOF_VOID_P LESS 8 AND NOT MINGW)
     message(WARNING "libminizip needs 64bit - stopping here")
-    return()
-endif(CMAKE_SIZEOF_VOID_P LESS 8)
-
+#    return()
+endif(CMAKE_SIZEOF_VOID_P LESS 8 AND NOT MINGW)
+
+#============================================================================
+# CPack
+#============================================================================
+set(CPACK_PACKAGE_VENDOR "zlib-Project")
+set(CPACK_PACKAGE_DESCRIPTION_FILE ${minizip_SOURCE_DIR}/MiniZip64_info.txt)
+set(CPACK_RESOURCE_FILE_LICENSE ${minizip_SOURCE_DIR}/../../LICENSE)
+set(CPACK_RESOURCE_FILE_README ${minizip_SOURCE_DIR}/MiniZip64_info.txt)
+
+#============================================================================
+# configuration
+#============================================================================
 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)
@@ -23,6 +36,7 @@ include(CheckFunctionExists)
 include(CheckIncludeFile)
 include(CheckCSourceCompiles)
 include(CMakePackageConfigHelpers)
+include(CPack)
 include(GNUInstallDirs)
 
 if(MINIZIP_ENABLE_BZIP2)

From 5a2ca3cb80ed5834ba51dc610154fe7fb1a36d54 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Thu, 26 Dec 2024 23:09:28 +0100
Subject: [PATCH 077/128] CMake: Add packaging to tests.

---
 .github/workflows/cmake.yml | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml
index d8f97f8d6..3ee931876 100644
--- a/.github/workflows/cmake.yml
+++ b/.github/workflows/cmake.yml
@@ -12,6 +12,7 @@ jobs:
             os: ubuntu-latest
             compiler: gcc
             cflags: -Wall -Wextra
+            pkgtgt: package package_source
 
           # Test out of source builds
           - name: Ubuntu GCC OSB
@@ -20,50 +21,59 @@ jobs:
             cflags: -Wall -Wextra
             build-dir: ../build
             src-dir: ../zlib
+            pkgtgt: package package_source
 
           - name: Ubuntu GCC -O3
             os: ubuntu-latest
             compiler: gcc
             cflags: -O3 -Wall -Wextra
+            pkgtgt: package package_source
 
           - name: Ubuntu Clang
             os: ubuntu-latest
             compiler: clang
             cflags: -Wall -Wextra
+            pkgtgt: package package_source
 
           - name: Ubuntu Clang Debug
             os: ubuntu-latest
             compiler: clang
             cflags: -Wall -Wextra
             build-config: Debug
+            pkgtgt: package package_source
 
           - name: Windows MSVC Win32
             os: windows-latest
             compiler: cl
             cflags: /W3
             cmake-args: -A Win32
+            pkgtgt: PACKAGE
 
           - name: Windows MSVC Win64
             os: windows-latest
             compiler: cl
             cflags: /W3
             cmake-args: -A x64
+            pkgtgt: PACKAGE
 
           - name: Windows GCC
             os: windows-latest
             compiler: gcc
             cflags: -Wall -Wextra
             cmake-args: -G Ninja
+            pkgtgt: package
 
           - name: macOS Clang
             os: macos-latest
             compiler: clang
             cflags: -Wall -Wextra
+            pkgtgt: package
 
           - name: macOS GCC
             os: macos-latest
             compiler: gcc-12
             cflags: -Wall -Wextra
+            pkgtgt: package
 
     steps:
     - name: Checkout repository
@@ -87,6 +97,10 @@ jobs:
       run: ctest -C Release --output-on-failure --max-width 120
       working-directory: ${{ matrix.build-dir || '.' }}
 
+    - name: create packages
+      run: cmake --build ${{ matrix.build-dir || '.' }} --config ${{ matrix.build-config || 'Release' }} -t ${{ matrix.pkgtgt }}
+      working-directory: ${{ matrix.build-dir || '.' }}
+
     - name: Upload build errors
       uses: actions/upload-artifact@v4
       if: failure()

From c99a4ae60f140ce2d60726f193a86bb50307858b Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Fri, 27 Dec 2024 10:32:31 +0100
Subject: [PATCH 078/128] CMake: Depend on bzip2 only if it's found.

---
 contrib/minizip/minizipConfig.cmake.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/minizip/minizipConfig.cmake.in b/contrib/minizip/minizipConfig.cmake.in
index b23454f2b..ba7ecde8c 100644
--- a/contrib/minizip/minizipConfig.cmake.in
+++ b/contrib/minizip/minizipConfig.cmake.in
@@ -1,5 +1,5 @@
 set(minizip_VERSION @minizip_VERSION@)
-set(MINIZIP_ENABLE_BZIP2 @MINIZIP_ENABLE_BZIP2@)
+set(MINIZIP_ENABLE_BZIP2 @BZIP2_FOUND@)
 @PACKAGE_INIT@
 include(CMakeFindDependencyMacro)
 find_dependency(ZLIB CONFIG)

From 373bc1d7c564fdff67847d215eb0b6a5896c23a2 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Fri, 27 Dec 2024 10:58:25 +0100
Subject: [PATCH 079/128] CMake: Uncomment stop sign.

---
 contrib/minizip/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/minizip/CMakeLists.txt b/contrib/minizip/CMakeLists.txt
index 39e0dcb50..932476c2b 100644
--- a/contrib/minizip/CMakeLists.txt
+++ b/contrib/minizip/CMakeLists.txt
@@ -8,7 +8,7 @@ project(minizip
 
 if(CMAKE_SIZEOF_VOID_P LESS 8 AND NOT MINGW)
     message(WARNING "libminizip needs 64bit - stopping here")
-#    return()
+    return()
 endif(CMAKE_SIZEOF_VOID_P LESS 8 AND NOT MINGW)
 
 #============================================================================

From d82da0fd1586f6df3fa1c5751f627a12bda8d2fe Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Fri, 27 Dec 2024 10:58:44 +0100
Subject: [PATCH 080/128] CMake: Remove cmake out-of-tree test.

CMake is designed for that.
---
 .github/workflows/cmake.yml | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml
index 3ee931876..40aae6083 100644
--- a/.github/workflows/cmake.yml
+++ b/.github/workflows/cmake.yml
@@ -14,15 +14,6 @@ jobs:
             cflags: -Wall -Wextra
             pkgtgt: package package_source
 
-          # Test out of source builds
-          - name: Ubuntu GCC OSB
-            os: ubuntu-latest
-            compiler: gcc
-            cflags: -Wall -Wextra
-            build-dir: ../build
-            src-dir: ../zlib
-            pkgtgt: package package_source
-
           - name: Ubuntu GCC -O3
             os: ubuntu-latest
             compiler: gcc
@@ -85,21 +76,20 @@ jobs:
         choco install --no-progress ninja ${{ matrix.packages }}
 
     - name: Generate project files
-      run: cmake -S ${{ matrix.src-dir || '.' }} -B ${{ matrix.build-dir || '.' }} ${{ matrix.cmake-args }} -D CMAKE_BUILD_TYPE=${{ matrix.build-config || 'Release' }} -DZLIB_BUILD_MINIZIP=ON
+      run: cmake -S . -B ../build ${{ matrix.cmake-args }} -D CMAKE_BUILD_TYPE=${{ matrix.build-config || 'Release' }} -DZLIB_BUILD_MINIZIP=ON
       env:
         CC: ${{ matrix.compiler }}
         CFLAGS: ${{ matrix.cflags }}
 
     - name: Compile source code
-      run: cmake --build ${{ matrix.build-dir || '.' }} --config ${{ matrix.build-config || 'Release' }}
+      run: cmake --build ../build --config ${{ matrix.build-config || 'Release' }}
 
     - name: Run test cases
       run: ctest -C Release --output-on-failure --max-width 120
-      working-directory: ${{ matrix.build-dir || '.' }}
+      working-directory: ../build
 
     - name: create packages
-      run: cmake --build ${{ matrix.build-dir || '.' }} --config ${{ matrix.build-config || 'Release' }} -t ${{ matrix.pkgtgt }}
-      working-directory: ${{ matrix.build-dir || '.' }}
+      run: cmake --build ../build --config ${{ matrix.build-config || 'Release' }} -t ${{ matrix.pkgtgt }}
 
     - name: Upload build errors
       uses: actions/upload-artifact@v4
@@ -107,6 +97,6 @@ jobs:
       with:
         name: ${{ matrix.name }} (cmake)
         path: |
-          **/CMakeFiles/CMakeOutput.log
-          **/CMakeFiles/CMakeError.log
+          ../build/CMakeFiles/CMakeOutput.log
+          ../build/CMakeFiles/CMakeError.log
         retention-days: 7

From ede311d685a536fbf4a287818b70412baa14ca76 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Fri, 27 Dec 2024 16:15:03 +0100
Subject: [PATCH 081/128] CMake: Make bzip2 optional.

---
 contrib/minizip/CMakeLists.txt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/contrib/minizip/CMakeLists.txt b/contrib/minizip/CMakeLists.txt
index 932476c2b..b97a6264d 100644
--- a/contrib/minizip/CMakeLists.txt
+++ b/contrib/minizip/CMakeLists.txt
@@ -166,8 +166,9 @@ if(MINIZIP_BUILD_SHARED)
         VERSIOM ${minizip_VERSION}
         SOVERSION ${minizip_VERSION_MAJOR})
     target_link_libraries(libminizip
-        PUBLIC
+        PRIVATE
             $<$<BOOL:${BZIP2_FOUND}>:BZip2::BZip2>
+        PUBLIC
             ZLIB::ZLIB)
 
     add_executable(minizip
@@ -221,8 +222,9 @@ if(MINIZIP_BUILD_STATIC)
     endif(CYGWIN)
 
     target_link_libraries(libminizipstatic
-        PUBLIC
+        PRIVATE
             $<$<BOOL:${BZIP2_FOUND}>:BZip2::BZip2>
+        PUBLIC
             ZLIB::ZLIBSTATIC)
 
     add_executable(minizipstatic

From 15a3751836739a987bfd1fb73d1c2f20ef85e69b Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Mon, 30 Dec 2024 10:56:16 +0100
Subject: [PATCH 082/128] CMake: Order the includes consistently.

---
 CMakeLists.txt                 | 5 +++--
 contrib/minizip/CMakeLists.txt | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9003fd5a8..f9e962059 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,11 +38,12 @@ if(NOT DEFINED CMAKE_BUILD_TYPE AND NOT IS_MULTI)
     message(STATUS "No CMAKE_BUILD_TYPE set -- using Release")
     set(CMAKE_BUILD_TYPE Release)
 endif(NOT DEFINED CMAKE_BUILD_TYPE AND NOT IS_MULTI)
-include(CheckTypeSize)
+
+include(CheckCSourceCompiles)
 include(CheckFunctionExists)
 include(CheckIncludeFile)
-include(CheckCSourceCompiles)
 include(CMakePackageConfigHelpers)
+include(CheckTypeSize)
 include(CPack)
 include(GNUInstallDirs)
 
diff --git a/contrib/minizip/CMakeLists.txt b/contrib/minizip/CMakeLists.txt
index b97a6264d..2cf23d26f 100644
--- a/contrib/minizip/CMakeLists.txt
+++ b/contrib/minizip/CMakeLists.txt
@@ -32,11 +32,11 @@ if(MINGW)
     option(MINIZIP_INSTALL_COMPAT_DLL "Install a copy as libminizip-1.dll" ON)
 endif(MINGW)
 
+include(CheckCSourceCompiles)
 include(CheckFunctionExists)
 include(CheckIncludeFile)
-include(CheckCSourceCompiles)
 include(CMakePackageConfigHelpers)
-include(CPack)
+include(CheckTypeSize)
 include(GNUInstallDirs)
 
 if(MINIZIP_ENABLE_BZIP2)

From f42008f5b49e8fd718f38771d587f8a6b3b71b5c Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Mon, 30 Dec 2024 10:56:46 +0100
Subject: [PATCH 083/128] CMake: Avoid double inclusion of CPack warning.

---
 CMakeLists.txt                 | 2 ++
 contrib/minizip/CMakeLists.txt | 4 ++++
 2 files changed, 6 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f9e962059..4785e1a64 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -47,6 +47,8 @@ include(CheckTypeSize)
 include(CPack)
 include(GNUInstallDirs)
 
+set(CPACK_INCLUDED TRUE)
+
 if(NOT ZLIB_CONF_WRITTEN)
     set(Z_PREFIX ${ZLIB_PREFIX})
     set(CONF_OUT_FILE ${zlib_BINARY_DIR}/zconf.h.cmakein)
diff --git a/contrib/minizip/CMakeLists.txt b/contrib/minizip/CMakeLists.txt
index 2cf23d26f..68aeed5bb 100644
--- a/contrib/minizip/CMakeLists.txt
+++ b/contrib/minizip/CMakeLists.txt
@@ -39,6 +39,10 @@ include(CMakePackageConfigHelpers)
 include(CheckTypeSize)
 include(GNUInstallDirs)
 
+if(NOT CPACK_INCLUDED)
+    include(CPack)
+endif(NOT CPACK_INCLUDED)
+
 if(MINIZIP_ENABLE_BZIP2)
     find_package(BZip2)
 endif(MINIZIP_ENABLE_BZIP2)

From 62b5b4eff81e5b8bc22a7e18f942ae103ea98483 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Mon, 30 Dec 2024 11:05:39 +0100
Subject: [PATCH 084/128] CMake: Make bzip2 required if it's requested.

---
 contrib/minizip/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/minizip/CMakeLists.txt b/contrib/minizip/CMakeLists.txt
index 68aeed5bb..0081f80f1 100644
--- a/contrib/minizip/CMakeLists.txt
+++ b/contrib/minizip/CMakeLists.txt
@@ -44,7 +44,7 @@ if(NOT CPACK_INCLUDED)
 endif(NOT CPACK_INCLUDED)
 
 if(MINIZIP_ENABLE_BZIP2)
-    find_package(BZip2)
+    find_package(BZip2 REQUIRED)
 endif(MINIZIP_ENABLE_BZIP2)
 
 #

From 5fd63442f92ad7a0c90d008c7daac7a726fa9e19 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Mon, 30 Dec 2024 11:06:28 +0100
Subject: [PATCH 085/128] CMake: Search for zlib by CONFIG to get all needed
 targets.

---
 contrib/minizip/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/minizip/CMakeLists.txt b/contrib/minizip/CMakeLists.txt
index 0081f80f1..e4d4e216b 100644
--- a/contrib/minizip/CMakeLists.txt
+++ b/contrib/minizip/CMakeLists.txt
@@ -88,7 +88,7 @@ check_c_source_compiles(
 unset(CMAKE_REQUIRED_FLAGS)
 
 if(NOT TARGET ZLIB::ZLIB)
-    find_package(ZLIB REQUIRED)
+    find_package(ZLIB REQUIRED CONFIG)
 endif(NOT TARGET ZLIB::ZLIB)
 
 set(LIBMINIZIP_SRCS

From 8fee881981d472caa96d8f3c4d75f6067dbb2944 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Mon, 30 Dec 2024 11:06:40 +0100
Subject: [PATCH 086/128] CMake: Clean up formatting.

---
 contrib/minizip/CMakeLists.txt | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/contrib/minizip/CMakeLists.txt b/contrib/minizip/CMakeLists.txt
index e4d4e216b..d394ff9ca 100644
--- a/contrib/minizip/CMakeLists.txt
+++ b/contrib/minizip/CMakeLists.txt
@@ -71,6 +71,7 @@ unset(CMAKE_REQUIRED_DEFINITIONS) # clear variable
 
 #
 # Check visibility attribute is supported
+#
 if(MSVC)
     set(CMAKE_REQUIRED_FLAGS "-WX")
 else(MSVC)
@@ -185,7 +186,6 @@ if(MINIZIP_BUILD_SHARED)
             $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
             $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>)
     target_link_libraries(minizip PRIVATE MINIZIP::minizip)
-
     add_executable(miniunzip
         ${MINIUNZIP_SRCS}
         ${MINIUNZIP_HDRS})
@@ -199,7 +199,6 @@ if(MINIZIP_BUILD_SHARED)
 endif(MINIZIP_BUILD_SHARED)
 
 if(MINIZIP_BUILD_STATIC)
-
     add_library(libminizipstatic STATIC
         ${LIBMINIZIP_SRCS}
         ${LIBMINIZIP_HDRS})
@@ -241,7 +240,6 @@ if(MINIZIP_BUILD_STATIC)
             $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
             $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>)
     target_link_libraries(minizipstatic PRIVATE MINIZIP::minizipstatic)
-
     add_executable(miniunzipstatic
         ${MINIUNZIP_SRCS}
         ${MINIUNZIP_HDRS})

From d51255713b9f7438ac9ecb2d144d8253fb9f8be8 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Mon, 30 Dec 2024 11:13:59 +0100
Subject: [PATCH 087/128] CMake: Do not link to bzip2.

---
 contrib/minizip/CMakeLists.txt | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/contrib/minizip/CMakeLists.txt b/contrib/minizip/CMakeLists.txt
index d394ff9ca..d84984cbd 100644
--- a/contrib/minizip/CMakeLists.txt
+++ b/contrib/minizip/CMakeLists.txt
@@ -170,11 +170,7 @@ if(MINIZIP_BUILD_SHARED)
         OUTPUT_NAME minizip
         VERSIOM ${minizip_VERSION}
         SOVERSION ${minizip_VERSION_MAJOR})
-    target_link_libraries(libminizip
-        PRIVATE
-            $<$<BOOL:${BZIP2_FOUND}>:BZip2::BZip2>
-        PUBLIC
-            ZLIB::ZLIB)
+    target_link_libraries(libminizip PUBLIC ZLIB::ZLIB)
 
     add_executable(minizip
         ${MINIZIP_SRCS}
@@ -224,12 +220,7 @@ if(MINIZIP_BUILD_STATIC)
             SUFFIX ".dll.a")
     endif(CYGWIN)
 
-    target_link_libraries(libminizipstatic
-        PRIVATE
-            $<$<BOOL:${BZIP2_FOUND}>:BZip2::BZip2>
-        PUBLIC
-            ZLIB::ZLIBSTATIC)
-
+    target_link_libraries(libminizipstatic PUBLIC ZLIB::ZLIBSTATIC)
     add_executable(minizipstatic
         ${MINIZIP_SRCS}
         ${MINIZIP_HDRS})

From e843c631d6c677bb8585c31b0b960d281cfc42bc Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Mon, 30 Dec 2024 11:14:36 +0100
Subject: [PATCH 088/128] CMake: Refine tests.

---
 contrib/minizip/test/CMakeLists.txt           | 116 ++++++++----------
 .../add_subdirectory_exclude_test.cmake.in    |  38 +++---
 .../test/add_subdirectory_test.cmake.in       |  38 +++---
 .../minizip/test/find_package_test.cmake.in   |  35 +++---
 test/CMakeLists.txt                           |  48 ++++----
 test/add_subdirectory_exclude_test.cmake.in   |  21 ++--
 test/add_subdirectory_test.cmake.in           |  21 ++--
 test/find_package_test.cmake.in               |  18 +--
 8 files changed, 169 insertions(+), 166 deletions(-)

diff --git a/contrib/minizip/test/CMakeLists.txt b/contrib/minizip/test/CMakeLists.txt
index 345718c31..2da5ae144 100644
--- a/contrib/minizip/test/CMakeLists.txt
+++ b/contrib/minizip/test/CMakeLists.txt
@@ -1,26 +1,39 @@
-add_test(NAME minizip_test_install
-    COMMAND ${CMAKE_COMMAND} --install ${zlib_BINARY_DIR}
-        --prefix ${CMAKE_CURRENT_BINARY_DIR}/test_install
-        --config $<CONFIG>
-    WORKING_DIRECTORY ${zlib_BINARY_DIR})
-
-set_tests_properties(minizip_test_install
-    PROPERTIES
-        FIXTURES_SETUP minizip_install)
+#if we are built from with zlib, use this path's)
+if(DEFINED ZLIB_BUILD_SHARED)
+    set(WORK_DIR ${zlib_BINARY_DIR})
+    set(inst_setup minizip_minizip_install)
+else(DEFINED ZLIB_BUILD_SHARED)
+    set(WORK_DIR ${minizip_BINARY_DIR})
+    set(inst_setup minizip_minizip_install)
+    set(ZLIB_ARG "-DZLIB_DIR=${ZLIB_DIR}")
+
+    add_test(NAME minizip_install
+        COMMAND ${CMAKE_COMMAND} --install ${minizip_BINARY_DIR}
+            --prefix ${CMAKE_CURRENT_BINARY_DIR}/test_install
+            --config $<CONFIG>
+        WORKING_DIRECTORY ${minizip_BINARY_DIR})
+
+    set_tests_properties(minizip_install
+        PROPERTIES
+            FIXTURES_SETUP minizip_install)
+endif(DEFINED ZLIB_BUILD_SHARED)
 
 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_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)
+    ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test/CMakeLists.txt
+    @ONLY)
 
 configure_file(
     ${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_test.cmake.in
-    ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectoy_test/CMakeLists.txt)
+    ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test/CMakeLists.txt
+    @ONLY)
 
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_exclude_test.cmake.in
-    ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test/CMakeLists.txt)
+    ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test/CMakeLists.txt
+    @ONLY)
 
 # CMAKE_GENERATOR_PLATFORM doesn't work in the if
 set(GENERATOR ${CMAKE_GENERATOR_PLATFORM})
@@ -32,108 +45,83 @@ endif(GENERATOR)
 #
 # findpackage_test
 #
-add_test(NAME minizip_configure_find_package
+add_test(NAME minizip_find_package_configure
     COMMAND ${CMAKE_COMMAND}
         ${PLATFORM}
         -B${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build
         -DCMAKE_BUILD_TYPE=$<CONFIG>
         -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}
+        -DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install
+        ${ZLIB_ARG}
         --fresh
         -G "${CMAKE_GENERATOR}"
         -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
 
-add_test(NAME minizip_build_find_package
+add_test(NAME minizip_find_package_build
     COMMAND ${CMAKE_COMMAND} --build .
     --config $<CONFIG>
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
 
-add_test(NAME minizip_test_find_package
-    COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
-    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
-
-set_tests_properties(minizip_configure_find_package PROPERTIES
-    FIXTURES_REQUIRED minizip_install
+set_tests_properties(minizip_find_package_configure PROPERTIES
+    FIXTURES_REQUIRED ${inst_setup}
     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)
+set_tests_properties(minizip_find_package_build PROPERTIES
+    FIXTURES_REQUIRED mzfp_config)
 
 #
 # add_subdirectory_test
 #
-add_test(NAME minizip_configure_add_subdirectory
+add_test(NAME minizip_add_subdirectory_configure
     COMMAND ${CMAKE_COMMAND}
     ${PLATFORM}
     -B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build
     -DCMAKE_BUILD_TYPE=$<CONFIG>
     -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
     -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-    -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_install
+    -DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install
+    ${ZLIB_ARG}
     --fresh
     -G "${CMAKE_GENERATOR}"
-    -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
+    -S${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test)
 
-add_test(NAME minizip_build_add_subdirectory
+add_test(NAME minizip_add_subdirectory_build
     COMMAND ${CMAKE_COMMAND} --build .
     --config $<CONFIG>
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
 
-add_test(NAME minizip_test_add_subdirectory
-    COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
-    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
-
-set_tests_properties(minizip_configure_add_subdirectory PROPERTIES
-    FIXTURES_REQUIRED minizip_install
+set_tests_properties(minizip_add_subdirectory_configure PROPERTIES
+    FIXTURES_REQUIRED ${inst_setup}
     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)
+set_tests_properties(minizip_add_subdirectory_build PROPERTIES
+    FIXTURES_REQUIRED mzas_config)
 
 #
 # add_subdirectory_exclude_test
 #
-add_test(NAME minizip_configure_add_subdirectory_exclude
+add_test(NAME minizip_add_subdirectory_exclude_configure
     COMMAND ${CMAKE_COMMAND}
     ${PLATFORM}
     -B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build
     -DCMAKE_BUILD_TYPE=$<CONFIG>
     -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
     -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-    -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_install
+    -DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install
+    ${ZLIB_ARG}
     --fresh
     -G "${CMAKE_GENERATOR}"
-    -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
+    -S${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test)
 
-add_test(NAME minizip_build_add_subdirectory_exclude
+add_test(NAME minizip_add_subdirectory_exclude_build
     COMMAND ${CMAKE_COMMAND} --build .
     --config $<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 $<CONFIG>
-    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
-
-set_tests_properties(minizip_configure_add_subdirectory_exclude PROPERTIES
-    FIXTURES_REQUIRED minizip_install
+set_tests_properties(minizip_add_subdirectory_exclude_configure PROPERTIES
+    FIXTURES_REQUIRED ${inst_setup}
     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)
+set_tests_properties(minizip_add_subdirectory_exclude_build PROPERTIES
+    FIXTURES_REQUIRED mzasx_config)
diff --git a/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in b/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in
index 92d6a4d74..277b2cd33 100644
--- a/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in
+++ b/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in
@@ -1,25 +1,27 @@
 cmake_minimum_required(VERSION 3.12)
 
-project(zlib_find_package_test
+project(minizip_add_subdirectory_exclude_from_all
     LANGUAGES C
-    VERSION ${zlib_VERSION})
+    VERSION @minizip_VERSION@)
 
-enable_testing()
-set(ZLIB_BUILD_TESTING OFF)
-add_subdirectory(${zlib_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/zlib EXCLUDE_FROM_ALL)
+option(MINIZIP_BUILD_TESTING "" OFF)
+option(MINIZIP_BUILD_SHARED "" @MINIZIP_BUILD_SHARED@)
+option(MINIZIP_BUILD_STATIC "" @MINIZIP_BUILD_STATIC@)
 
-if(${ZLIB_BUILD_SHARED})
-    add_executable(test_example ${zlib_SOURCE_DIR}/test/example.c)
-    target_link_libraries(test_example ZLIB::ZLIB)
+add_subdirectory(@minizip_SOURCE_DIR@ ${CMAKE_CURRENT_BINARY_DIR}/minizip EXCLUDE_FROM_ALL)
 
-    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})
+set(MINIZIP_SRCS
+    @minizip_SOURCE_DIR@/ioapi.c
+    $<$<BOOL:${WIN32}>:@minizip_SOURCE_DIR@/iowin32.c>
+    @minizip_SOURCE_DIR@/minizip.c
+    @minizip_SOURCE_DIR@/zip.c)
 
-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})
+if(MINIZIP_BUILD_SHARED)
+    add_executable(test_example ${MINIZIP_SRCS})
+    target_link_libraries(test_example MINIZIP::minizip)
+endif(MINIZIP_BUILD_SHARED)
+
+if(MINIZIP_BUILD_STATIC)
+    add_executable(test_example_static ${MINIZIP_SRCS})
+    target_link_libraries(test_example_static MINIZIP::minizipstatic)
+endif(MINIZIP_BUILD_STATIC)
diff --git a/contrib/minizip/test/add_subdirectory_test.cmake.in b/contrib/minizip/test/add_subdirectory_test.cmake.in
index fc2a9e0cb..a29b415b1 100644
--- a/contrib/minizip/test/add_subdirectory_test.cmake.in
+++ b/contrib/minizip/test/add_subdirectory_test.cmake.in
@@ -1,25 +1,27 @@
 cmake_minimum_required(VERSION 3.12)
 
-project(zlib_find_package_test
+project(minizip_add_subdirectory_exclude_from_all
     LANGUAGES C
-    VERSION ${zlib_VERSION})
+    VERSION @minizip_VERSION@)
 
-enable_testing()
-set(ZLIB_BUILD_TESTING OFF)
-add_subdirectory(${zlib_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/zlib)
+option(MINIZIP_BUILD_TESTING "" OFF)
+option(MINIZIP_BUILD_SHARED "" @MINIZIP_BUILD_SHARED@)
+option(MINIZIP_BUILD_STATIC "" @MINIZIP_BUILD_STATIC@)
 
-if(${ZLIB_BUILD_SHARED})
-    add_executable(test_example ${zlib_SOURCE_DIR}/test/example.c)
-    target_link_libraries(test_example ZLIB::ZLIB)
+add_subdirectory(@minizip_SOURCE_DIR@ ${CMAKE_CURRENT_BINARY_DIR}/minizip)
 
-    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})
+set(MINIZIP_SRCS
+    @minizip_SOURCE_DIR@/ioapi.c
+    $<$<BOOL:${WIN32}>:@minizip_SOURCE_DIR@/iowin32.c>
+    @minizip_SOURCE_DIR@/minizip.c
+    @minizip_SOURCE_DIR@/zip.c)
 
-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})
+if(MINIZIP_BUILD_SHARED)
+    add_executable(test_example ${MINIZIP_SRCS})
+    target_link_libraries(test_example MINIZIP::minizip)
+endif(MINIZIP_BUILD_SHARED)
+
+if(MINIZIP_BUILD_STATIC)
+    add_executable(test_example_static ${MINIZIP_SRCS})
+    target_link_libraries(test_example_static MINIZIP::minizipstatic)
+endif(MINIZIP_BUILD_STATIC)
diff --git a/contrib/minizip/test/find_package_test.cmake.in b/contrib/minizip/test/find_package_test.cmake.in
index 3df1edecc..b56b5593b 100644
--- a/contrib/minizip/test/find_package_test.cmake.in
+++ b/contrib/minizip/test/find_package_test.cmake.in
@@ -1,24 +1,25 @@
 cmake_minimum_required(VERSION 3.12)
 
-project(zlib_find_package_test
+project(minizip_find_package
     LANGUAGES C
-    VERSION ${zlib_VERSION})
+    VERSION @minizip_VERSION@)
 
-enable_testing()
-find_package(ZLIB ${zlib_VERSION} CONFIG REQUIRED)
+option(MINIZIP_BUILD_SHARED "" @MINIZIP_BUILD_SHARED@)
+option(MINIZIP_BUILD_STATIC "" @MINIZIP_BUILD_STATIC@)
+find_package(minizip ${minizip_VERSION} CONFIG REQUIRED)
 
-if(${ZLIB_BUILD_SHARED})
-    add_executable(test_example ${zlib_SOURCE_DIR}/test/example.c)
-    target_link_libraries(test_example ZLIB::ZLIB)
+set(MINIZIP_SRCS
+    @minizip_SOURCE_DIR@/ioapi.c
+    $<$<BOOL:${WIN32}>:@minizip_SOURCE_DIR@/iowin32.c>
+    @minizip_SOURCE_DIR@/minizip.c
+    @minizip_SOURCE_DIR@/zip.c)
 
-    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(MINIZIP_BUILD_SHARED)
+    add_executable(test_example ${MINIZIP_SRCS})
+    target_link_libraries(test_example MINIZIP::minizip)
+endif(MINIZIP_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})
+if(MINIZIP_BUILD_STATIC)
+    add_executable(test_example_static ${MINIZIP_SRCS})
+    target_link_libraries(test_example_static MINIZIP::minizipstatic)
+endif(MINIZIP_BUILD_STATIC)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 1f399f4b7..b03d23e31 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -121,18 +121,21 @@ set_tests_properties(zlib_install
         FIXTURES_SETUP zlib_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_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)
+    ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test/CMakeLists.txt
+    @ONLY)
 
 configure_file(
     ${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_test.cmake.in
-    ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectoy_test/CMakeLists.txt)
+    ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test/CMakeLists.txt
+    @ONLY)
 
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_exclude_test.cmake.in
-    ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test/CMakeLists.txt)
+    ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test/CMakeLists.txt
+    @ONLY)
 
 # CMAKE_GENERATOR_PLATFORM doesn't work in the if
 set(GENERATOR ${CMAKE_GENERATOR_PLATFORM})
@@ -143,7 +146,7 @@ endif(GENERATOR)
 #
 # findpackage_test
 #
-add_test(NAME zlib_configure_find_package
+add_test(NAME zlib_find_package_configure
     COMMAND ${CMAKE_COMMAND}
         ${PLATFORM}
         -B${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build
@@ -151,36 +154,35 @@ add_test(NAME zlib_configure_find_package
         -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 zlib_build_find_package
+add_test(NAME zlib_find_package_build
     COMMAND ${CMAKE_COMMAND} --build .
     --config $<CONFIG>
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
 
-add_test(NAME zlib_test_find_package
+add_test(NAME zlib_find_package_test
     COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
 
-set_tests_properties(zlib_configure_find_package PROPERTIES
+set_tests_properties(zlib_find_package_configure PROPERTIES
     FIXTURES_REQUIRED zlib_install
     FIXTURES_SETUP fp_config)
 
-set_tests_properties(zlib_build_find_package PROPERTIES
+set_tests_properties(zlib_find_package_build PROPERTIES
     FIXTURES_REQUIRED fp_config
     FIXTURES_SETUP fp_build)
 
-set_tests_properties(zlib_test_find_package PROPERTIES
+set_tests_properties(zlib_find_package_test PROPERTIES
     FIXTURES_REQUIRED fp_build
     ENVIRONMENT CTEST_OUTPUT_ON_FAILURE=1)
 
 #
 # add_subdirectory_test
 #
-add_test(NAME zlib_configure_add_subdirectory
+add_test(NAME zlib_add_subdirectory_configure
     COMMAND ${CMAKE_COMMAND}
     ${PLATFORM}
     -B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build
@@ -192,31 +194,31 @@ add_test(NAME zlib_configure_add_subdirectory
     -G "${CMAKE_GENERATOR}"
     -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
 
-add_test(NAME zlib_build_add_subdirectory
+add_test(NAME zlib_add_subdirectory_build
     COMMAND ${CMAKE_COMMAND} --build .
     --config $<CONFIG>
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
 
-add_test(NAME zlib_test_add_subdirectory
+add_test(NAME zlib_add_subdirectory_test
     COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
 
-set_tests_properties(zlib_configure_add_subdirectory PROPERTIES
+set_tests_properties(zlib_add_subdirectory_configure PROPERTIES
     FIXTURES_REQUIRED zlib_install
     FIXTURES_SETUP as_config)
 
-set_tests_properties(zlib_build_add_subdirectory PROPERTIES
+set_tests_properties(zlib_add_subdirectory_build PROPERTIES
     FIXTURES_REQUIRED as_config
     FIXTURES_SETUP as_build)
 
-set_tests_properties(zlib_test_add_subdirectory PROPERTIES
+set_tests_properties(zlib_add_subdirectory_test PROPERTIES
     FIXTURES_REQUIRED as_build
     ENVIRONMENT CTEST_OUTPUT_ON_FAILURE=1)
 
 #
 # add_subdirectory_exclude_test
 #
-add_test(NAME zlib_configure_add_subdirectory_exclude
+add_test(NAME zlib_add_subdirectory_exclude_configure
     COMMAND ${CMAKE_COMMAND}
     ${PLATFORM}
     -B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build
@@ -228,23 +230,23 @@ add_test(NAME zlib_configure_add_subdirectory_exclude
     -G "${CMAKE_GENERATOR}"
     -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
 
-add_test(NAME zlib_build_add_subdirectory_exclude
+add_test(NAME zlib_add_subdirectory_exclude_build
     COMMAND ${CMAKE_COMMAND} --build .
     --config $<CONFIG>
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
 
-add_test(NAME zlib_test_add_subdirectory_exclude
+add_test(NAME zlib_add_subdirectory_exclude_test
     COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
 
-set_tests_properties(zlib_configure_add_subdirectory_exclude PROPERTIES
+set_tests_properties(zlib_add_subdirectory_exclude_configure PROPERTIES
     FIXTURES_REQUIRED zlib_install
     FIXTURES_SETUP asx_config)
 
-set_tests_properties(zlib_build_add_subdirectory_exclude PROPERTIES
+set_tests_properties(zlib_add_subdirectory_exclude_build PROPERTIES
     FIXTURES_REQUIRED as_config
     FIXTURES_SETUP asx_build)
 
-set_tests_properties(zlib_test_add_subdirectory_exclude PROPERTIES
+set_tests_properties(zlib_add_subdirectory_exclude_test PROPERTIES
     FIXTURES_REQUIRED asx_build
     ENVIRONMENT CTEST_OUTPUT_ON_FAILURE=1)
diff --git a/test/add_subdirectory_exclude_test.cmake.in b/test/add_subdirectory_exclude_test.cmake.in
index 9516546a8..c751a7a5f 100644
--- a/test/add_subdirectory_exclude_test.cmake.in
+++ b/test/add_subdirectory_exclude_test.cmake.in
@@ -2,24 +2,27 @@ cmake_minimum_required(VERSION 3.10)
 
 project(zlib_find_package_test
     LANGUAGES C
-    VERSION ${zlib_VERSION})
+    VERSION @zlib_VERSION@)
 
 enable_testing()
-set(ZLIB_BUILD_TESTING OFF)
-add_subdirectory(${zlib_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/zlib EXCLUDE_FROM_ALL)
+option(ZLIB_BUILD_TESTING "" OFF)
+option(ZLIB_BUILD_SHARED "" @ZLIB_BUILD_SHARED@)
+option(ZLIB_BUILD_STATIC "" @ZLIB_BUILD_STATIC@)
 
-if(${ZLIB_BUILD_SHARED})
-    add_executable(test_example ${zlib_SOURCE_DIR}/test/example.c)
+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})
+endif(ZLIB_BUILD_SHARED)
 
-if(${ZLIB_BUILD_STATIC})
-    add_executable(test_example_static ${zlib_SOURCE_DIR}/test/example.c)
+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})
+endif(ZLIB_BUILD_STATIC)
diff --git a/test/add_subdirectory_test.cmake.in b/test/add_subdirectory_test.cmake.in
index 72933bacb..d5e3a05a8 100644
--- a/test/add_subdirectory_test.cmake.in
+++ b/test/add_subdirectory_test.cmake.in
@@ -2,24 +2,27 @@ cmake_minimum_required(VERSION 3.10)
 
 project(zlib_find_package_test
     LANGUAGES C
-    VERSION ${zlib_VERSION})
+    VERSION @zlib_VERSION@)
 
 enable_testing()
-set(ZLIB_BUILD_TESTING OFF)
-add_subdirectory(${zlib_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/zlib)
+option(ZLIB_BUILD_TESTING "" OFF)
+option(ZLIB_BUILD_SHARED "" @ZLIB_BUILD_SHARED@)
+option(ZLIB_BUILD_STATIC "" @ZLIB_BUILD_STATIC@)
 
-if(${ZLIB_BUILD_SHARED})
-    add_executable(test_example ${zlib_SOURCE_DIR}/test/example.c)
+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})
+endif(ZLIB_BUILD_SHARED)
 
-if(${ZLIB_BUILD_STATIC})
-    add_executable(test_example_static ${zlib_SOURCE_DIR}/test/example.c)
+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})
+endif(@ZLIB_BUILD_STATIC)
diff --git a/test/find_package_test.cmake.in b/test/find_package_test.cmake.in
index 2adab4c11..728a1a4f0 100644
--- a/test/find_package_test.cmake.in
+++ b/test/find_package_test.cmake.in
@@ -2,23 +2,25 @@ cmake_minimum_required(VERSION 3.10)
 
 project(zlib_find_package_test
     LANGUAGES C
-    VERSION ${zlib_VERSION})
+    VERSION @zlib_VERSION@)
 
 enable_testing()
-find_package(ZLIB ${zlib_VERSION} CONFIG REQUIRED)
+find_package(ZLIB @zlib_VERSION@ CONFIG REQUIRED)
+option(ZLIB_BUILD_SHARED "" @ZLIB_BUILD_SHARED@)
+option(ZLIB_BUILD_STATIC "" @ZLIB_BUILD_STATIC@)
 
-if(${ZLIB_BUILD_SHARED})
-    add_executable(test_example ${zlib_SOURCE_DIR}/test/example.c)
+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})
+endif(ZLIB_BUILD_SHARED)
 
-if(${ZLIB_BUILD_STATIC})
-    add_executable(test_example_static ${zlib_SOURCE_DIR}/test/example.c)
+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})
+endif(ZLIB_BUILD_STATIC)

From abf7487d6c3dd12dde50bd54489cfc99cef59770 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Tue, 31 Dec 2024 12:55:38 +0100
Subject: [PATCH 089/128] CMake: Add components selection.

---
 CMakeLists.txt                         | 23 +++++++++---------
 contrib/minizip/CMakeLists.txt         | 23 +++++++++---------
 contrib/minizip/minizipConfig.cmake.in | 32 ++++++++++++++++++++++----
 zlibConfig.cmake.in                    | 27 ++++++++++++++++++++--
 4 files changed, 76 insertions(+), 29 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4785e1a64..d14ca3077 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -231,10 +231,14 @@ if(ZLIB_INSTALL_LIBRARIES)
     if(ZLIB_BUILD_SHARED)
         install(TARGETS zlib
             COMPONENT Runtime
-            EXPORT zlibExport
+            EXPORT zlibSharedExport
             RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
             ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
             LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
+        install(EXPORT zlibSharedExport
+                FILE ZLIB-shared.cmake
+                NAMESPACE ZLIB::
+                DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
         if(ZLIB_INSTALL_COMPAT_DLL)
             install(FILES  $<TARGET_FILE:zlib>
                 COMPONENT Runtime
@@ -255,23 +259,26 @@ if(ZLIB_INSTALL_LIBRARIES)
     if(ZLIB_BUILD_STATIC)
         install(TARGETS zlibstatic
             COMPONENT Development
-            EXPORT zlibExport
+            EXPORT zlibStaticExport
             RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
             ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
             LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
+        install(EXPORT zlibStaticExport
+            FILE ZLIB-static.cmake
+            NAMESPACE ZLIB::
+            DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
+
         if(ZLIB_INSTALL_COMPAT_DLL AND MINGW)
             install(FILES  $<TARGET_FILE:zlibstatic>
                 COMPONENT Development
                 RENAME libz.dll.a
                 DESTINATION "${CMAKE_INSTALL_LIBDIR}")
         endif(ZLIB_INSTALL_COMPAT_DLL AND MINGW)
-
     endif(ZLIB_BUILD_STATIC)
 
     configure_package_config_file(${zlib_SOURCE_DIR}/zlibConfig.cmake.in
         ${zlib_BINARY_DIR}/ZLIBConfig.cmake
-        INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib
-        NO_CHECK_REQUIRED_COMPONENTS_MACRO)
+        INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
 
     write_basic_package_version_file(
         "${zlib_BINARY_DIR}/ZLIBConfigVersion.cmake"
@@ -282,12 +289,6 @@ if(ZLIB_INSTALL_LIBRARIES)
         ${zlib_BINARY_DIR}/ZLIBConfig.cmake
         ${zlib_BINARY_DIR}/ZLIBConfigVersion.cmake
         DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
-
-    install(EXPORT zlibExport
-        FILE ZLIB.cmake
-        DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib
-        NAMESPACE ZLIB::)
-
     install(FILES ${ZLIB_PUBLIC_HDRS}
             COMPONENT Development
             DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
diff --git a/contrib/minizip/CMakeLists.txt b/contrib/minizip/CMakeLists.txt
index d84984cbd..c4b425ade 100644
--- a/contrib/minizip/CMakeLists.txt
+++ b/contrib/minizip/CMakeLists.txt
@@ -247,10 +247,14 @@ if(MINIZIP_INSTALL)
     if(MINIZIP_BUILD_SHARED)
         install(TARGETS libminizip minizip miniunzip
             COMPONENT Runtime
-            EXPORT minizipExport
+            EXPORT minizipSharedExport
             RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
             ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
             LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
+        install(EXPORT minizipSharedExport
+                FILE minizip-shared.cmake
+                NAMESPACE MINIZIP::
+                DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/minizip)
         if(MINIZIP_INSTALL_COMPAT_DLL)
             install(FILES  $<TARGET_FILE:libminizip>
                 COMPONENT Runtime
@@ -273,32 +277,27 @@ if(MINIZIP_INSTALL)
                 COMPONENT Development
             TARGETS  minizipstatic miniunzipstatic
                 COMPONENT Runtime
-            EXPORT minizipExport
+            EXPORT minizipStaticExport
             RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
             ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
             LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
+        install(EXPORT minizipStaticExport
+                FILE minizip-static.cmake
+                NAMESPACE MINIZIP::
+                DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/minizip)
     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)
-
+        INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/minizip)
     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}")
diff --git a/contrib/minizip/minizipConfig.cmake.in b/contrib/minizip/minizipConfig.cmake.in
index ba7ecde8c..ef0004d6d 100644
--- a/contrib/minizip/minizipConfig.cmake.in
+++ b/contrib/minizip/minizipConfig.cmake.in
@@ -1,6 +1,30 @@
-set(minizip_VERSION @minizip_VERSION@)
-set(MINIZIP_ENABLE_BZIP2 @BZIP2_FOUND@)
 @PACKAGE_INIT@
+
+set(_minizip_supported_components "")
 include(CMakeFindDependencyMacro)
-find_dependency(ZLIB CONFIG)
-INCLUDE (${CMAKE_CURRENT_LIST_DIR}/minizip.cmake)
+if(@MINIZIP_BUILD_SHARED@)
+    list(APPEND _minizip_supported_components shared)
+endif(@MINIZIP_BUILD_SHARED@)
+
+if(@MINIZIP_BUILD_STATIC@)
+    list(APPEND _minizip_supported_components static)
+endif(@MINIZIP_BUILD_STATIC@)
+
+if(minizip_FIND_COMPONENTS)
+    find_dependency(ZLIB CONFIG COMPONENTS ${minizip_FIND_COMPONENTS})
+
+    foreach(_comp ${minizip_FIND_COMPONENTS})
+        if (NOT _comp IN_LIST _MINIZIP_supported_components)
+            set(minizip_FOUND False)
+            set(minizip_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
+        endif(NOT _comp IN_LIST _MINIZIP_supported_components)
+
+        include("${CMAKE_CURRENT_LIST_DIR}/minizip-${_comp}.cmake")
+    endforeach(_comp ${ZLIB_FIND_COMPONENTS})
+else(minizip_FIND_COMPONENTS)
+    find_dependency(ZLIB CONFIG)
+
+    foreach(_component_config IN LISTS _minizip_supported_components)
+        include("${CMAKE_CURRENT_LIST_DIR}/minizip-${_component_config}.cmake")
+    endforeach(_component_config IN LISTS _minizip_supported_components)
+endif(minizip_FIND_COMPONENTS)
diff --git a/zlibConfig.cmake.in b/zlibConfig.cmake.in
index 8e64b6fc3..d7a849b70 100644
--- a/zlibConfig.cmake.in
+++ b/zlibConfig.cmake.in
@@ -1,3 +1,26 @@
-set(zlib_VERSION @zlib_VERSION@)
 @PACKAGE_INIT@
-INCLUDE (${CMAKE_CURRENT_LIST_DIR}/ZLIB.cmake)
+
+set(_ZLIB_supported_components "")
+
+if(@ZLIB_BUILD_SHARED@)
+    list(APPEND _ZLIB_supported_components shared)
+endif(@ZLIB_BUILD_SHARED@)
+
+if(@ZLIB_BUILD_STATIC@)
+    list(APPEND _ZLIB_supported_components static)
+endif(@ZLIB_BUILD_STATIC@)
+
+if(ZLIB_FIND_COMPONENTS)
+    foreach(_comp ${ZLIB_FIND_COMPONENTS})
+        if (NOT _comp IN_LIST _ZLIB_supported_components)
+            set(ZLIB_FOUND False)
+            set(ZLIB_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
+        endif(NOT _comp IN_LIST _ZLIB_supported_components)
+
+        include("${CMAKE_CURRENT_LIST_DIR}/ZLIB-${_comp}.cmake")
+    endforeach(_comp ${ZLIB_FIND_COMPONENTS})
+else(ZLIB_FIND_COMPONENTS)
+    foreach(_component_config IN LISTS _ZLIB_supported_components)
+        include("${CMAKE_CURRENT_LIST_DIR}/ZLIB-${_component_config}.cmake")
+    endforeach(_component_config IN LISTS _ZLIB_supported_components)
+endif(ZLIB_FIND_COMPONENTS)

From 10a12ec427cca2b701648f6722a8875f6e67dd01 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Tue, 31 Dec 2024 13:13:14 +0100
Subject: [PATCH 090/128] CMake: Correct wording for minizip options.

---
 contrib/minizip/CMakeLists.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/minizip/CMakeLists.txt b/contrib/minizip/CMakeLists.txt
index c4b425ade..fd43e828c 100644
--- a/contrib/minizip/CMakeLists.txt
+++ b/contrib/minizip/CMakeLists.txt
@@ -22,8 +22,8 @@ set(CPACK_RESOURCE_FILE_README ${minizip_SOURCE_DIR}/MiniZip64_info.txt)
 #============================================================================
 # configuration
 #============================================================================
-option(MINIZIP_BUILD_SHARED "Enable building zlib shared library" ON)
-option(MINIZIP_BUILD_STATIC "Enable building zlib static library" ON)
+option(MINIZIP_BUILD_SHARED "Enable building minizip shared library" ON)
+option(MINIZIP_BUILD_STATIC "Enable building minizip 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)

From 33b8e6f507c5cba92ef88bb66ca886bdfda5e2f5 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Tue, 31 Dec 2024 13:16:28 +0100
Subject: [PATCH 091/128] CMake: Rename option to ZLIB_INSTALL.

Not only the libraries are installed.
---
 CMakeLists.txt | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d14ca3077..b38dcb163 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -22,7 +22,7 @@ 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_INSTALL "Enable installation of zlib" ON)
 option(ZLIB_PREFIX
     "prefix for all types and library functions, see zconf.h.in"
     OFF)
@@ -227,7 +227,7 @@ if(ZLIB_BUILD_STATIC)
         OUTPUT_NAME z${zlib_static_suffix})
 endif(ZLIB_BUILD_STATIC)
 
-if(ZLIB_INSTALL_LIBRARIES)
+if(ZLIB_INSTALL)
     if(ZLIB_BUILD_SHARED)
         install(TARGETS zlib
             COMPONENT Runtime
@@ -308,7 +308,7 @@ if(ZLIB_INSTALL_LIBRARIES)
     install(FILES ${ZLIB_PC}
             COMPONENT Development
             DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
-endif(ZLIB_INSTALL_LIBRARIES)
+endif(ZLIB_INSTALL)
 
 #============================================================================
 # Tests

From 42a670ec200d276616e5d0bcab667c7e2c5de10d Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Tue, 31 Dec 2024 13:37:08 +0100
Subject: [PATCH 092/128] CMake: Restore lost variable.

---
 contrib/minizip/minizipConfig.cmake.in | 1 +
 1 file changed, 1 insertion(+)

diff --git a/contrib/minizip/minizipConfig.cmake.in b/contrib/minizip/minizipConfig.cmake.in
index ef0004d6d..14db08dce 100644
--- a/contrib/minizip/minizipConfig.cmake.in
+++ b/contrib/minizip/minizipConfig.cmake.in
@@ -1,5 +1,6 @@
 @PACKAGE_INIT@
 
+set(MINIZIP_ENABLE_BZIP2 @MINIZIP_ENABLE_BZIP2@)
 set(_minizip_supported_components "")
 include(CMakeFindDependencyMacro)
 if(@MINIZIP_BUILD_SHARED@)

From 1be9392124c2e6dbc2c0f683fafab7482bdb3d33 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Tue, 31 Dec 2024 13:39:43 +0100
Subject: [PATCH 093/128] CMake: Add a README.cmake.

---
 README.cmake | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
 create mode 100644 README.cmake

diff --git a/README.cmake b/README.cmake
new file mode 100644
index 000000000..96d492c96
--- /dev/null
+++ b/README.cmake
@@ -0,0 +1,76 @@
+For building with cmake at least version 3.10 (minizip 3.12) is needed
+
+In most cases the usual "mkdir build && cd build && cmake .." will create everything you need, however
+if you want something off default you can adjust several options fit your needs. Every option is
+list below (excluding the cmake-standard options), they can be set via cmake-gui or on cmdline with
+
+	-D<option>=ON/OFF
+
+## ZLIB-options with defaults ##
+
+ZLIB_BUILD_TESTING=ON -- Enable Zlib Examples as tests
+
+ZLIB_BUILD_SHARED=ON -- Enable building zlib shared library
+
+ZLIB_BUILD_STATIC=ON -- Enable building zlib static library
+
+ZLIB_BUILD_MINIZIP=ON -- Enable building libminizip contrib library
+If this option is turned on, additional options are available from minizip (see below)
+
+ZLIB_INSTALL=ON -- Enable installation of zlib
+
+ZLIB_PREFIX=OFF -- prefix for all types and library functions, see zconf.h.in
+
+ZLIB_INSTALL_COMPAT_DLL=ON -- Install a copy as zlib1.dll
+This option is only on windows available and may/will be turned off and removed somewhen in the future.
+If you rely cmake for finding and using zlib, this can be turned off, as zlib1.dll will never be used.
+
+## minizip-options with defaults ##
+
+MINIZIP_BUILD_SHARED=ON Enable building minizip shared library
+
+MINIZIP_BUILD_STATIC=ON Enable building minizip static library
+
+MINIZIP_BUILD_TESTING=ON Enable testing of minizip
+
+MINIZIP_ENABLE_BZIP2=ON Build minizip withj bzip2 support
+A usable installation of bzip2 is needed or config will fail. Turn this option of in this case.
+
+MINIZIP_INSTALL=ON Enable installation of minizip
+
+MINIZIP_INSTALL_COMPAT_DLL=ON Install a copy as libminizip-1.dll
+This option is only available on mingw as they tend to name this lib different. Maybe this will also be
+removed in the future as. If you rely cmake for finding and using zlib, this can be turned off, as
+the other file will never be used.
+
+## Using the libs ##
+
+To pull in what you need it's enough to just write
+
+	find_package(ZLIB CONFIG)
+or
+	find_package(minizip CONFIG)
+
+in your CMakeLists.txt, however it is advised to specify what you really want via:
+
+	find_package(ZLIB CONFIG COMPONENTS shared static REQUIRED)
+or
+	find_package(minizip CONFIG COMPONENTS shared static REQUIRED)
+
+As it's possible to only build the shared or the static lib, you can make sure that everything you need
+is found. If no COMPONENTS are requested, everything that is found will satisfy your request. If the
+libraries are optional in you project, you can omit the REQUIRED and check yourself if the targets you
+want to link against are created.
+
+When you search for minizip, it will search zlib for you, so only one of both is needed.
+
+## Imported targets ##
+When found the following targets are created for you:
+
+ZLIB::ZLIB and ZLIB:ZLIBSTATIC for zlib
+MINIZIP::minizip and MINIZIP::minizipstatic for minizip
+
+In addition a var called  MINIZIP_ENABLE_BZIP2 is exported so you can check if you got a bzip2 enabled
+version of the lib. As linking against libbz2 is only needed if you use functions from that set, it's
+no hard dep and you have to make sure a working bzip2-installation is found and linked in your binary.
+

From c31099862f61eea5481d5c5690dd95e4bd7096be Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Tue, 31 Dec 2024 14:01:49 +0100
Subject: [PATCH 094/128] CMake: Add one more alias for llvm-cov.

---
 test/CMakeLists.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index b03d23e31..fbf2bee1f 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -70,6 +70,7 @@ if(ZLIB_BUILD_STATIC)
 
         if(${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
             set(llvm_names llvm_cov)
+            list(APPEND llvm_names llvm-cov
 
             foreach(ver RANGE 11 99)
               list(APPEND llvm_names llvm-cov-${ver})

From 7667ca55931302d8e35c37a46851eb02191d465f Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Tue, 31 Dec 2024 14:02:13 +0100
Subject: [PATCH 095/128] CMake: Re-enable Cygwin and MSYS tests.

---
 .github/workflows/{msys-cygwin.txt => msys-cygwin.yml} | 0
 test/CMakeLists.txt                                    | 2 +-
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename .github/workflows/{msys-cygwin.txt => msys-cygwin.yml} (100%)

diff --git a/.github/workflows/msys-cygwin.txt b/.github/workflows/msys-cygwin.yml
similarity index 100%
rename from .github/workflows/msys-cygwin.txt
rename to .github/workflows/msys-cygwin.yml
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index fbf2bee1f..b9bcdfa13 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -70,7 +70,7 @@ if(ZLIB_BUILD_STATIC)
 
         if(${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
             set(llvm_names llvm_cov)
-            list(APPEND llvm_names llvm-cov
+            list(APPEND llvm_names llvm-cov)
 
             foreach(ver RANGE 11 99)
               list(APPEND llvm_names llvm-cov-${ver})

From b8ae23d4c839093b3f63fb2af85f1cc3d6562c86 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Tue, 31 Dec 2024 14:18:49 +0100
Subject: [PATCH 096/128] CMake: Disable bzip2 for tests.

It's not installed everywhere.
---
 .github/workflows/c-std.yml                                 | 4 ++--
 .github/workflows/cmake.yml                                 | 2 +-
 contrib/minizip/test/add_subdirectory_exclude_test.cmake.in | 1 +
 contrib/minizip/test/add_subdirectory_test.cmake.in         | 1 +
 4 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/c-std.yml b/.github/workflows/c-std.yml
index bc9311045..a99cdb569 100644
--- a/.github/workflows/c-std.yml
+++ b/.github/workflows/c-std.yml
@@ -141,7 +141,7 @@ jobs:
     - name: Generate project files with tests (cmake)
       if: matrix.builder == 'cmake'
       run: |
-        cmake -S . -B ./build2 -D CMAKE_BUILD_TYPE=Release ${{ matrix.os.cmake-opt }} -DZLIB_BUILD_MINIZIP=ON
+        cmake -S . -B ./build2 -D CMAKE_BUILD_TYPE=Release ${{ matrix.os.cmake-opt }} -DZLIB_BUILD_MINIZIP=ON -DMINIZIP_ENABLE_BZIP2=OFF
       env:
         CC: ${{ matrix.compiler }}
         CFLAGS: -std=${{ matrix.std.value }} ${{ matrix.arch.compiler-opt }} -Wall -Wextra
@@ -215,7 +215,7 @@ jobs:
 
     - name: Generate project files with tests (cmake)
       run: |
-        cmake -S . -B ./build2 ${{ matrix.arch.value }} -D CMAKE_BUILD_TYPE=Release -DZLIB_BUILD_MINIZIP=ON
+        cmake -S . -B ./build2 ${{ matrix.arch.value }} -D CMAKE_BUILD_TYPE=Release -DZLIB_BUILD_MINIZIP=ON -DMINIZIP_ENABLE_BZIP2=OFF
       env:
         CC: ${{ matrix.compiler }}
         CFLAGS: ${{ matrix.std.value }}
diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml
index 40aae6083..1b6171158 100644
--- a/.github/workflows/cmake.yml
+++ b/.github/workflows/cmake.yml
@@ -76,7 +76,7 @@ jobs:
         choco install --no-progress ninja ${{ matrix.packages }}
 
     - name: Generate project files
-      run: cmake -S . -B ../build ${{ matrix.cmake-args }} -D CMAKE_BUILD_TYPE=${{ matrix.build-config || 'Release' }} -DZLIB_BUILD_MINIZIP=ON
+      run: cmake -S . -B ../build ${{ matrix.cmake-args }} -D CMAKE_BUILD_TYPE=${{ matrix.build-config || 'Release' }} -DZLIB_BUILD_MINIZIP=ON -DMINIZIP_ENABLE_BZIP2=OFF
       env:
         CC: ${{ matrix.compiler }}
         CFLAGS: ${{ matrix.cflags }}
diff --git a/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in b/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in
index 277b2cd33..f662cda35 100644
--- a/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in
+++ b/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in
@@ -7,6 +7,7 @@ project(minizip_add_subdirectory_exclude_from_all
 option(MINIZIP_BUILD_TESTING "" OFF)
 option(MINIZIP_BUILD_SHARED "" @MINIZIP_BUILD_SHARED@)
 option(MINIZIP_BUILD_STATIC "" @MINIZIP_BUILD_STATIC@)
+option(MINIZIP_ENABLE_BZIP2 "" @MINIZIP_ENABLE_BZIP2@)
 
 add_subdirectory(@minizip_SOURCE_DIR@ ${CMAKE_CURRENT_BINARY_DIR}/minizip EXCLUDE_FROM_ALL)
 
diff --git a/contrib/minizip/test/add_subdirectory_test.cmake.in b/contrib/minizip/test/add_subdirectory_test.cmake.in
index a29b415b1..be5c66409 100644
--- a/contrib/minizip/test/add_subdirectory_test.cmake.in
+++ b/contrib/minizip/test/add_subdirectory_test.cmake.in
@@ -7,6 +7,7 @@ project(minizip_add_subdirectory_exclude_from_all
 option(MINIZIP_BUILD_TESTING "" OFF)
 option(MINIZIP_BUILD_SHARED "" @MINIZIP_BUILD_SHARED@)
 option(MINIZIP_BUILD_STATIC "" @MINIZIP_BUILD_STATIC@)
+option(MINIZIP_ENABLE_BZIP2 "" @MINIZIP_ENABLE_BZIP2@)
 
 add_subdirectory(@minizip_SOURCE_DIR@ ${CMAKE_CURRENT_BINARY_DIR}/minizip)
 

From b9cf26c056fa422d97ddd77657ca49602f6b58d2 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Tue, 31 Dec 2024 15:52:30 +0100
Subject: [PATCH 097/128] CMake: Increase CMake minimum version to 3.12.

For HOMPAGE_URL.
---
 CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b38dcb163..7212ea153 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.10)
+cmake_minimum_required(VERSION 3.12)
 
 project(zlib
     LANGUAGES C

From 00cbe1d6b1abf6d766bb69c622ee1fcf725d57df Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Tue, 31 Dec 2024 19:10:41 +0100
Subject: [PATCH 098/128] CMake: Disable testing on Cygwin.

---
 .github/workflows/msys-cygwin.yml | 64 +++++++++++++++----------------
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/.github/workflows/msys-cygwin.yml b/.github/workflows/msys-cygwin.yml
index 5ad7a7343..276959b30 100644
--- a/.github/workflows/msys-cygwin.yml
+++ b/.github/workflows/msys-cygwin.yml
@@ -40,35 +40,35 @@ jobs:
     - name: Run tests
       run: ctest --output-on-failure --test-dir build -C Release
 
-  cygwin:
-    strategy:
-      fail-fast: false
-    runs-on: windows-latest
-    defaults:
-      run:
-        shell: C:\cygwin\bin\bash.exe --login -o igncr '{0}'
-    name: Cygwin
-    steps:
-    - name: Checkout
-      uses: actions/checkout@v4
-      with:
-        fetch-depth: 0
-    - name: Setup cygwin
-      uses: cygwin/cygwin-install-action@master
-      with:
-        packages: >-
-          cmake
-          cygwin-devel
-          gcc-core
-          gcc-g++
-          ninja
-    - name: Configure
-      run: |
-        cmake /cygdrive/d/a/zlib/zlib \
-          -B build \
-          -DCMAKE_BUILD_TYPE=Release \
-          -G Ninja
-    - name: Build
-      run: cmake --build build --config Release
-    - name: Run tests
-      run: ctest --output-on-failure --test-dir build -C Release
+#  cygwin:
+#    strategy:
+#      fail-fast: false
+#    runs-on: windows-latest
+#    defaults:
+#      run:
+#        shell: C:\cygwin\bin\bash.exe --login -o igncr '{0}'
+#    name: Cygwin
+#    steps:
+#    - name: Checkout
+#      uses: actions/checkout@v4
+#      with:
+#        fetch-depth: 0
+#    - name: Setup cygwin
+#      uses: cygwin/cygwin-install-action@master
+#      with:
+#        packages: >-
+#          cmake
+#          cygwin-devel
+#          gcc-core
+#          gcc-g++
+#          ninja
+#    - name: Configure
+#      run: |
+#        cmake /cygdrive/d/a/zlib/zlib \
+#          -B build \
+#          -DCMAKE_BUILD_TYPE=Release \
+#          -G Ninja
+#    - name: Build
+#      run: cmake --build build --config Release
+#    - name: Run tests
+#      run: ctest --output-on-failure --test-dir build -C Release

From 4f2671d50cf0f8632c9f6e84b884aba5031e4016 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Fri, 3 Jan 2025 09:19:50 +0100
Subject: [PATCH 099/128] CMake: Remove unused variable.

---
 CMakeLists.txt | 1 -
 1 file changed, 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7212ea153..2ce9419b5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -168,7 +168,6 @@ endif(WIN32)
 if(ZLIB_BUILD_SHARED)
     add_library(zlib SHARED
         ${ZLIB_SRCS}
-        ${ZLIB_DLL_SRCS}
         ${ZLIB_PUBLIC_HDRS}
         ${ZLIB_PRIVATE_HDRS}
         $<$<OR:$<BOOL:${WIN32}>,$<BOOL:${CYGWIN}>>:win32/zlib1.rc>)

From 8b8a124eb42b027dceab01c7d4942a18c756d28e Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Fri, 3 Jan 2025 09:50:16 +0100
Subject: [PATCH 100/128] CMake: Add cmake-format.yaml and reformat the cmake
 files.

---
 .cmake-format.yaml                            | 245 +++++++++++
 CMakeLists.txt                                | 224 +++++-----
 contrib/minizip/CMakeLists.txt                | 391 ++++++++----------
 contrib/minizip/minizipConfig.cmake.in        |   2 +-
 contrib/minizip/test/CMakeLists.txt           | 146 ++++---
 .../add_subdirectory_exclude_test.cmake.in    |   9 +-
 .../test/add_subdirectory_test.cmake.in       |   6 +-
 .../minizip/test/find_package_test.cmake.in   |   6 +-
 test/CMakeLists.txt                           | 306 +++++++-------
 test/add_subdirectory_exclude_test.cmake.in   |   9 +-
 test/add_subdirectory_test.cmake.in           |   6 +-
 test/find_package_test.cmake.in               |   6 +-
 zlibConfig.cmake.in                           |   2 +-
 13 files changed, 798 insertions(+), 560 deletions(-)
 create mode 100644 .cmake-format.yaml

diff --git a/.cmake-format.yaml b/.cmake-format.yaml
new file mode 100644
index 000000000..9c554da15
--- /dev/null
+++ b/.cmake-format.yaml
@@ -0,0 +1,245 @@
+_help_parse: Options affecting listfile parsing
+parse:
+  _help_additional_commands:
+  - Specify structure for custom cmake functions
+  additional_commands:
+    foo:
+      flags:
+      - BAR
+      - BAZ
+      kwargs:
+        HEADERS: '*'
+        SOURCES: '*'
+        DEPENDS: '*'
+  _help_override_spec:
+  - Override configurations per-command where available
+  override_spec: {}
+  _help_vartags:
+  - Specify variable tags.
+  vartags: []
+  _help_proptags:
+  - Specify property tags.
+  proptags: []
+_help_format: Options affecting formatting.
+format:
+  _help_disable:
+  - Disable formatting entirely, making cmake-format a no-op
+  disable: false
+  _help_line_width:
+  - How wide to allow formatted cmake files
+  line_width: 80
+  _help_tab_size:
+  - How many spaces to tab for indent
+  tab_size: 4
+  _help_use_tabchars:
+  - If true, lines are indented using tab characters (utf-8
+  - 0x09) instead of <tab_size> space characters (utf-8 0x20).
+  - In cases where the layout would require a fractional tab
+  - character, the behavior of the  fractional indentation is
+  - governed by <fractional_tab_policy>
+  use_tabchars: false
+  _help_fractional_tab_policy:
+  - If <use_tabchars> is True, then the value of this variable
+  - indicates how fractional indentions are handled during
+  - whitespace replacement. If set to 'use-space', fractional
+  - indentation is left as spaces (utf-8 0x20). If set to
+  - '`round-up` fractional indentation is replaced with a single'
+  - tab character (utf-8 0x09) effectively shifting the column
+  - to the next tabstop
+  fractional_tab_policy: use-space
+  _help_max_subgroups_hwrap:
+  - If an argument group contains more than this many sub-groups
+  - (parg or kwarg groups) then force it to a vertical layout.
+  max_subgroups_hwrap: 2
+  _help_max_pargs_hwrap:
+  - If a positional argument group contains more than this many
+  - arguments, then force it to a vertical layout.
+  max_pargs_hwrap: 6
+  _help_max_rows_cmdline:
+  - If a cmdline positional group consumes more than this many
+  - lines without nesting, then invalidate the layout (and nest)
+  max_rows_cmdline: 2
+  _help_separate_ctrl_name_with_space:
+  - If true, separate flow control names from their parentheses
+  - with a space
+  separate_ctrl_name_with_space: false
+  _help_separate_fn_name_with_space:
+  - If true, separate function names from parentheses with a
+  - space
+  separate_fn_name_with_space: false
+  _help_dangle_parens:
+  - If a statement is wrapped to more than one line, than dangle
+  - the closing parenthesis on its own line.
+  dangle_parens: false
+  _help_dangle_align:
+  - If the trailing parenthesis must be 'dangled' on its on
+  - 'line, then align it to this reference: `prefix`: the start'
+  - 'of the statement,  `prefix-indent`: the start of the'
+  - 'statement, plus one indentation  level, `child`: align to'
+  - the column of the arguments
+  dangle_align: prefix
+  _help_min_prefix_chars:
+  - If the statement spelling length (including space and
+  - parenthesis) is smaller than this amount, then force reject
+  - nested layouts.
+  min_prefix_chars: 4
+  _help_max_prefix_chars:
+  - If the statement spelling length (including space and
+  - parenthesis) is larger than the tab width by more than this
+  - amount, then force reject un-nested layouts.
+  max_prefix_chars: 10
+  _help_max_lines_hwrap:
+  - If a candidate layout is wrapped horizontally but it exceeds
+  - this many lines, then reject the layout.
+  max_lines_hwrap: 2
+  _help_line_ending:
+  - What style line endings to use in the output.
+  line_ending: unix
+  _help_command_case:
+  - Format command names consistently as 'lower' or 'upper' case
+  command_case: canonical
+  _help_keyword_case:
+  - Format keywords consistently as 'lower' or 'upper' case
+  keyword_case: unchanged
+  _help_always_wrap:
+  - A list of command names which should always be wrapped
+  always_wrap: []
+  _help_enable_sort:
+  - If true, the argument lists which are known to be sortable
+  - will be sorted lexicographicall
+  enable_sort: true
+  _help_autosort:
+  - If true, the parsers may infer whether or not an argument
+  - list is sortable (without annotation).
+  autosort: false
+  _help_require_valid_layout:
+  - By default, if cmake-format cannot successfully fit
+  - everything into the desired linewidth it will apply the
+  - last, most aggressive attempt that it made. If this flag is
+  - True, however, cmake-format will print error, exit with non-
+  - zero status code, and write-out nothing
+  require_valid_layout: false
+  _help_layout_passes:
+  - A dictionary mapping layout nodes to a list of wrap
+  - decisions. See the documentation for more information.
+  layout_passes: {}
+_help_markup: Options affecting comment reflow and formatting.
+markup:
+  _help_bullet_char:
+  - What character to use for bulleted lists
+  bullet_char: '*'
+  _help_enum_char:
+  - What character to use as punctuation after numerals in an
+  - enumerated list
+  enum_char: .
+  _help_first_comment_is_literal:
+  - If comment markup is enabled, don't reflow the first comment
+  - block in each listfile. Use this to preserve formatting of
+  - your copyright/license statements.
+  first_comment_is_literal: false
+  _help_literal_comment_pattern:
+  - If comment markup is enabled, don't reflow any comment block
+  - which matches this (regex) pattern. Default is `None`
+  - (disabled).
+  literal_comment_pattern: null
+  _help_fence_pattern:
+  - Regular expression to match preformat fences in comments
+  - default= ``r'^\s*([`~]{3}[`~]*)(.*)$'``
+  fence_pattern: ^\s*([`~]{3}[`~]*)(.*)$
+  _help_ruler_pattern:
+  - Regular expression to match rulers in comments default=
+  - '``r''^\s*[^\w\s]{3}.*[^\w\s]{3}$''``'
+  ruler_pattern: ^\s*[^\w\s]{3}.*[^\w\s]{3}$
+  _help_explicit_trailing_pattern:
+  - If a comment line matches starts with this pattern then it
+  - is explicitly a trailing comment for the preceding argument.
+  - Default is '#<'
+  explicit_trailing_pattern: '#<'
+  _help_hashruler_min_length:
+  - If a comment line starts with at least this many consecutive
+  - hash characters, then don't lstrip() them off. This allows
+  - for lazy hash rulers where the first hash char is not
+  - separated by space
+  hashruler_min_length: 10
+  _help_canonicalize_hashrulers:
+  - If true, then insert a space between the first hash char and
+  - remaining hash chars in a hash ruler, and normalize its
+  - length to fill the column
+  canonicalize_hashrulers: true
+  _help_enable_markup:
+  - enable comment markup parsing and reflow
+  enable_markup: true
+_help_lint: Options affecting the linter
+lint:
+  _help_disabled_codes:
+  - a list of lint codes to disable
+  disabled_codes: []
+  _help_function_pattern:
+  - regular expression pattern describing valid function names
+  function_pattern: '[0-9a-z_]+'
+  _help_macro_pattern:
+  - regular expression pattern describing valid macro names
+  macro_pattern: '[0-9A-Z_]+'
+  _help_global_var_pattern:
+  - regular expression pattern describing valid names for
+  - variables with global (cache) scope
+  global_var_pattern: '[A-Z][0-9A-Z_]+'
+  _help_internal_var_pattern:
+  - regular expression pattern describing valid names for
+  - variables with global scope (but internal semantic)
+  internal_var_pattern: _[A-Z][0-9A-Z_]+
+  _help_local_var_pattern:
+  - regular expression pattern describing valid names for
+  - variables with local scope
+  local_var_pattern: '[a-z][a-z0-9_]+'
+  _help_private_var_pattern:
+  - regular expression pattern describing valid names for
+  - privatedirectory variables
+  private_var_pattern: _[0-9a-z_]+
+  _help_public_var_pattern:
+  - regular expression pattern describing valid names for public
+  - directory variables
+  public_var_pattern: '[A-Z][0-9A-Z_]+'
+  _help_argument_var_pattern:
+  - regular expression pattern describing valid names for
+  - function/macro arguments and loop variables.
+  argument_var_pattern: '[a-z][a-z0-9_]+'
+  _help_keyword_pattern:
+  - regular expression pattern describing valid names for
+  - keywords used in functions or macros
+  keyword_pattern: '[A-Z][0-9A-Z_]+'
+  _help_max_conditionals_custom_parser:
+  - In the heuristic for C0201, how many conditionals to match
+  - within a loop in before considering the loop a parser.
+  max_conditionals_custom_parser: 2
+  _help_min_statement_spacing:
+  - Require at least this many newlines between statements
+  min_statement_spacing: 1
+  _help_max_statement_spacing:
+  - Require no more than this many newlines between statements
+  max_statement_spacing: 2
+  max_returns: 6
+  max_branches: 12
+  max_arguments: 5
+  max_localvars: 15
+  max_statements: 50
+_help_encode: Options affecting file encoding
+encode:
+  _help_emit_byteorder_mark:
+  - If true, emit the unicode byte-order mark (BOM) at the start
+  - of the file
+  emit_byteorder_mark: false
+  _help_input_encoding:
+  - Specify the encoding of the input file. Defaults to utf-8
+  input_encoding: utf-8
+  _help_output_encoding:
+  - Specify the encoding of the output file. Defaults to utf-8.
+  - Note that cmake only claims to support utf-8 so be careful
+  - when using anything else
+  output_encoding: utf-8
+_help_misc: Miscellaneous configurations options.
+misc:
+  _help_per_command:
+  - A dictionary containing any per-command configuration
+  - overrides. Currently only `command_case` is supported.
+  per_command: {}
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2ce9419b5..705409124 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,31 +1,31 @@
 cmake_minimum_required(VERSION 3.12)
 
-project(zlib
+project(
+    zlib
     LANGUAGES C
-    VERSION 1.3.1.1
+    VERSION 1.4.1.1
     HOMEPAGE_URL "https://zlib.net/"
     DESCRIPTION "a general-purpose lossless data-compression library")
 
-#============================================================================
+# ============================================================================
 # CPack
-#============================================================================
+# ============================================================================
 set(CPACK_PACKAGE_VENDOR "zlib-Project")
 set(CPACK_PACKAGE_DESCRIPTION_FILE ${zlib_SOURCE_DIR}/README)
 set(CPACK_RESOURCE_FILE_LICENSE ${zlib_SOURCE_DIR}/LICENSE)
 set(CPACK_RESOURCE_FILE_README ${zlib_SOURCE_DIR}/README)
 
-#============================================================================
+# ============================================================================
 # configuration
-#============================================================================
+# ============================================================================
 
 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 "Enable installation of zlib" ON)
-option(ZLIB_PREFIX
-    "prefix for all types and library functions, see zconf.h.in"
-    OFF)
+option(ZLIB_PREFIX "prefix for all types and library functions, see zconf.h.in"
+       OFF)
 mark_as_advanced(ZLIB_PREFIX)
 
 if(WIN32)
@@ -70,7 +70,9 @@ if(NOT ZLIB_CONF_WRITTEN)
     endforeach(item IN LISTS ${ZCONF_CONTENT})
 
     file(APPEND ${CONF_OUT_FILE} ${OUT_CONTENT})
-    set(ZLIB_CONF_WRITTEN TRUE CACHE BOOL "zconf.h.cmakein was created")
+    set(ZLIB_CONF_WRITTEN
+        TRUE
+        CACHE BOOL "zconf.h.cmakein was created")
     mark_as_advanced(ZLIB_CONF_WRITTEN)
 endif(NOT ZLIB_CONF_WRITTEN)
 
@@ -115,19 +117,15 @@ check_c_source_compiles(
 
 unset(CMAKE_COMPILE_FLAGS)
 set(ZLIB_PC ${zlib_BINARY_DIR}/zlib.pc)
-configure_file(${zlib_SOURCE_DIR}/zlib.pc.cmakein
-               ${ZLIB_PC} @ONLY)
-configure_file(${zlib_BINARY_DIR}/zconf.h.cmakein
-               ${zlib_BINARY_DIR}/zconf.h)
+configure_file(${zlib_SOURCE_DIR}/zlib.pc.cmakein ${ZLIB_PC} @ONLY)
+configure_file(${zlib_BINARY_DIR}/zconf.h.cmakein ${zlib_BINARY_DIR}/zconf.h)
 include_directories(${zlib_BINARY_DIR} ${zlib_SOURCE_DIR})
 
-#============================================================================
+# ============================================================================
 # zlib
-#============================================================================
+# ============================================================================
 
-set(ZLIB_PUBLIC_HDRS
-    ${zlib_BINARY_DIR}/zconf.h
-    zlib.h)
+set(ZLIB_PUBLIC_HDRS ${zlib_BINARY_DIR}/zconf.h zlib.h)
 
 set(ZLIB_PRIVATE_HDRS
     crc32.h
@@ -157,8 +155,10 @@ set(ZLIB_SRCS
     uncompr.c
     zutil.c)
 
-set_source_files_properties(win32/zlib1.rc PROPERTIES
-    COMPILE_FLAGS $<$<STREQUAL:${CMAKE_RC_OUTPUT_EXTENSION},.obj>:-DGCC_WINDRES>)
+set_source_files_properties(
+    win32/zlib1.rc
+    PROPERTIES COMPILE_FLAGS
+               $<$<STREQUAL:${CMAKE_RC_OUTPUT_EXTENSION},.obj>:-DGCC_WINDRES>)
 
 if(WIN32)
     set(zlib_static_suffix "s")
@@ -166,116 +166,126 @@ if(WIN32)
 endif(WIN32)
 
 if(ZLIB_BUILD_SHARED)
-    add_library(zlib SHARED
-        ${ZLIB_SRCS}
-        ${ZLIB_PUBLIC_HDRS}
-        ${ZLIB_PRIVATE_HDRS}
-        $<$<OR:$<BOOL:${WIN32}>,$<BOOL:${CYGWIN}>>:win32/zlib1.rc>)
+    add_library(
+        zlib SHARED ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}
+                    $<$<OR:$<BOOL:${WIN32}>,$<BOOL:${CYGWIN}>>:win32/zlib1.rc>)
     add_library(ZLIB::ZLIB ALIAS zlib)
-    target_include_directories(zlib PUBLIC
-        $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
-        $<BUILD_INTERFACE:${zlib_SOURCE_DIR}>
-        $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
-    target_compile_definitions(zlib
-        PRIVATE
-            $<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
-            $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
-            $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
-            $<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>
-        PUBLIC
-            $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
+    target_include_directories(
+        zlib
+        PUBLIC $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
+               $<BUILD_INTERFACE:${zlib_SOURCE_DIR}>
+               $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
+    target_compile_definitions(
+        zlib
+        PRIVATE $<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
+                $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
+                $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
+                $<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>
+        PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
     set(INSTALL_VERSION ${zlib_VERSION})
 
     if(NOT CYGWIN)
-        set_target_properties(zlib PROPERTIES
-            SOVERSION ${zlib_VERSION_MAJOR}
-            VERSION ${INSTALL_VERSION})
+        set_target_properties(zlib PROPERTIES SOVERSION ${zlib_VERSION_MAJOR}
+                                              VERSION ${INSTALL_VERSION})
     endif(NOT CYGWIN)
 
-    set_target_properties(zlib PROPERTIES
-        DEFINE_SYMBOL ZLIB_DLL
-        EXPORT_NAME ZLIB
-        OUTPUT_NAME z)
-    if(UNIX AND NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
+    set_target_properties(
+        zlib
+        PROPERTIES DEFINE_SYMBOL ZLIB_DLL
+                   EXPORT_NAME ZLIB
+                   OUTPUT_NAME z)
+    if(UNIX
+       AND NOT APPLE
+       AND NOT (CMAKE_SYSTEM_NAME STREQUAL AIX))
         # On unix-like platforms the library is almost always called libz
-        set_target_properties(zlib PROPERTIES
-            LINK_FLAGS "-Wl,--version-script,\"${zlib_SOURCE_DIR}/zlib.map\"")
-    endif(UNIX AND NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
+        set_target_properties(
+            zlib
+            PROPERTIES LINK_FLAGS
+                       "-Wl,--version-script,\"${zlib_SOURCE_DIR}/zlib.map\"")
+    endif(
+        UNIX
+        AND NOT APPLE
+        AND NOT (CMAKE_SYSTEM_NAME STREQUAL AIX))
 endif(ZLIB_BUILD_SHARED)
 
 if(ZLIB_BUILD_STATIC)
-    add_library(zlibstatic STATIC
-        ${ZLIB_SRCS}
-        ${ZLIB_PUBLIC_HDRS}
-        ${ZLIB_PRIVATE_HDRS})
+    add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS}
+                                  ${ZLIB_PRIVATE_HDRS})
     add_library(ZLIB::ZLIBSTATIC ALIAS zlibstatic)
-    target_include_directories(zlibstatic PUBLIC
-        $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
-        $<BUILD_INTERFACE:${zlib_SOURCE_DIR}>
-        $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
-    target_compile_definitions(zlibstatic
-        PRIVATE
-            $<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
-            $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
-            $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
-            $<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>
-        PUBLIC
-            $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
-    set_target_properties(zlibstatic PROPERTIES
-        EXPORT_NAME ZLIBSTATIC
-        OUTPUT_NAME z${zlib_static_suffix})
+    target_include_directories(
+        zlibstatic
+        PUBLIC $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
+               $<BUILD_INTERFACE:${zlib_SOURCE_DIR}>
+               $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
+    target_compile_definitions(
+        zlibstatic
+        PRIVATE $<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
+                $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
+                $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
+                $<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>
+        PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
+    set_target_properties(
+        zlibstatic PROPERTIES EXPORT_NAME ZLIBSTATIC OUTPUT_NAME
+                                                     z${zlib_static_suffix})
 endif(ZLIB_BUILD_STATIC)
 
 if(ZLIB_INSTALL)
     if(ZLIB_BUILD_SHARED)
-        install(TARGETS zlib
+        install(
+            TARGETS zlib
             COMPONENT Runtime
             EXPORT zlibSharedExport
             RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
             ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
             LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
-        install(EXPORT zlibSharedExport
-                FILE ZLIB-shared.cmake
-                NAMESPACE ZLIB::
-                DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
+        install(
+            EXPORT zlibSharedExport
+            FILE ZLIB-shared.cmake
+            NAMESPACE ZLIB::
+            DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
         if(ZLIB_INSTALL_COMPAT_DLL)
-            install(FILES  $<TARGET_FILE:zlib>
+            install(
+                FILES $<TARGET_FILE:zlib>
                 COMPONENT Runtime
                 RENAME zlib1.dll
                 DESTINATION "${CMAKE_INSTALL_BINDIR}")
         endif(ZLIB_INSTALL_COMPAT_DLL)
 
         if(MSVC)
-            install(FILES $<TARGET_PDB_FILE:zlib>
+            install(
+                FILES $<TARGET_PDB_FILE:zlib>
                 COMPONENT Runtime
                 DESTINATION ${CMAKE_INSTALL_BINDIR}
                 CONFIGURATIONS Debug OR RelWithDebInfo
-                OPTIONAL
-            )
+                OPTIONAL)
         endif(MSVC)
     endif(ZLIB_BUILD_SHARED)
 
     if(ZLIB_BUILD_STATIC)
-        install(TARGETS zlibstatic
+        install(
+            TARGETS zlibstatic
             COMPONENT Development
             EXPORT zlibStaticExport
             RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
             ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
             LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
-        install(EXPORT zlibStaticExport
+        install(
+            EXPORT zlibStaticExport
             FILE ZLIB-static.cmake
             NAMESPACE ZLIB::
             DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
 
         if(ZLIB_INSTALL_COMPAT_DLL AND MINGW)
-            install(FILES  $<TARGET_FILE:zlibstatic>
+            install(
+                FILES $<TARGET_FILE:zlibstatic>
                 COMPONENT Development
                 RENAME libz.dll.a
                 DESTINATION "${CMAKE_INSTALL_LIBDIR}")
         endif(ZLIB_INSTALL_COMPAT_DLL AND MINGW)
     endif(ZLIB_BUILD_STATIC)
 
-    configure_package_config_file(${zlib_SOURCE_DIR}/zlibConfig.cmake.in
+    configure_package_config_file(
+        ${zlib_SOURCE_DIR}/zlibConfig.cmake.in
         ${zlib_BINARY_DIR}/ZLIBConfig.cmake
         INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
 
@@ -284,34 +294,36 @@ if(ZLIB_INSTALL)
         VERSION "${zlib_VERSION}"
         COMPATIBILITY AnyNewerVersion)
 
-    install(FILES
-        ${zlib_BINARY_DIR}/ZLIBConfig.cmake
-        ${zlib_BINARY_DIR}/ZLIBConfigVersion.cmake
-        DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
-    install(FILES ${ZLIB_PUBLIC_HDRS}
-            COMPONENT Development
-            DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
-    install(FILES zlib.3
-            COMPONENT Docs
-            DESTINATION "${CMAKE_INSTALL_MANDIR}/man3")
-    install(FILES
-                LICENSE
-                doc/algorithm.txt
-                doc/crc-doc.1.0.pdf
-                doc/rfc1950.txt
-                doc/rfc1951.txt
-                doc/rfc1952.txt
-                doc/txtvsbin.txt
-            COMPONENT Docs
-            DESTINATION "${CMAKE_INSTALL_DOCDIR}/zlib")
-    install(FILES ${ZLIB_PC}
-            COMPONENT Development
-            DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
+    install(FILES ${zlib_BINARY_DIR}/ZLIBConfig.cmake
+                  ${zlib_BINARY_DIR}/ZLIBConfigVersion.cmake
+            DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
+    install(
+        FILES ${ZLIB_PUBLIC_HDRS}
+        COMPONENT Development
+        DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
+    install(
+        FILES zlib.3
+        COMPONENT Docs
+        DESTINATION "${CMAKE_INSTALL_MANDIR}/man3")
+    install(
+        FILES LICENSE
+              doc/algorithm.txt
+              doc/crc-doc.1.0.pdf
+              doc/rfc1950.txt
+              doc/rfc1951.txt
+              doc/rfc1952.txt
+              doc/txtvsbin.txt
+        COMPONENT Docs
+        DESTINATION "${CMAKE_INSTALL_DOCDIR}/zlib")
+    install(
+        FILES ${ZLIB_PC}
+        COMPONENT Development
+        DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
 endif(ZLIB_INSTALL)
 
-#============================================================================
+# ============================================================================
 # Tests
-#============================================================================
+# ============================================================================
 if(ZLIB_BUILD_TESTING)
     enable_testing()
     add_subdirectory(test)
diff --git a/contrib/minizip/CMakeLists.txt b/contrib/minizip/CMakeLists.txt
index fd43e828c..f252002d0 100644
--- a/contrib/minizip/CMakeLists.txt
+++ b/contrib/minizip/CMakeLists.txt
@@ -1,6 +1,7 @@
 cmake_minimum_required(VERSION 3.12)
 
-project(minizip
+project(
+    minizip
     VERSION 1.0.0
     LANGUAGES C
     DESCRIPTION "A library for creating zipfiles based in zlib"
@@ -11,17 +12,17 @@ if(CMAKE_SIZEOF_VOID_P LESS 8 AND NOT MINGW)
     return()
 endif(CMAKE_SIZEOF_VOID_P LESS 8 AND NOT MINGW)
 
-#============================================================================
+# ============================================================================
 # CPack
-#============================================================================
+# ============================================================================
 set(CPACK_PACKAGE_VENDOR "zlib-Project")
 set(CPACK_PACKAGE_DESCRIPTION_FILE ${minizip_SOURCE_DIR}/MiniZip64_info.txt)
 set(CPACK_RESOURCE_FILE_LICENSE ${minizip_SOURCE_DIR}/../../LICENSE)
 set(CPACK_RESOURCE_FILE_README ${minizip_SOURCE_DIR}/MiniZip64_info.txt)
 
-#============================================================================
+# ============================================================================
 # configuration
-#============================================================================
+# ============================================================================
 option(MINIZIP_BUILD_SHARED "Enable building minizip shared library" ON)
 option(MINIZIP_BUILD_STATIC "Enable building minizip static library" ON)
 option(MINIZIP_BUILD_TESTING "Enable testing of minizip" ON)
@@ -92,40 +93,17 @@ if(NOT TARGET ZLIB::ZLIB)
     find_package(ZLIB REQUIRED CONFIG)
 endif(NOT TARGET ZLIB::ZLIB)
 
-set(LIBMINIZIP_SRCS
-    ioapi.c
-    mztools.c
-    unzip.c
-    zip.c)
+set(LIBMINIZIP_SRCS ioapi.c mztools.c unzip.c zip.c)
 
-set(LIBMINIZIP_HDRS
-    crypt.h
-    ints.h
-    ioapi.h
-    mztools.h
-    unzip.h
-    zip.h)
+set(LIBMINIZIP_HDRS crypt.h ints.h ioapi.h mztools.h unzip.h zip.h)
 
-set(MINIZIP_SRCS
-    ioapi.c
-    $<$<BOOL:${WIN32}>:iowin32.c>
-    minizip.c
-    zip.c)
+set(MINIZIP_SRCS ioapi.c $<$<BOOL:${WIN32}>:iowin32.c> minizip.c zip.c)
 
-set(MINIZIP_HDRS
-    crypt.h
-    ints.h
-    ioapi.h
-    $<$<BOOL:${WIN32}>:iowin32.h>
-    skipset.h
-     zip.h)
+set(MINIZIP_HDRS crypt.h ints.h ioapi.h $<$<BOOL:${WIN32}>:iowin32.h> skipset.h
+                 zip.h)
 
-set(MINIUNZIP_SRCS
-    ioapi.c
-    $<$<BOOL:${WIN32}>:iowin32.c>
-    miniunz.c
-    unzip.c
-    zip.c)
+set(MINIUNZIP_SRCS ioapi.c $<$<BOOL:${WIN32}>:iowin32.c> miniunz.c unzip.c
+                   zip.c)
 
 set(MINIUNZIP_HDRS
     crypt.h
@@ -143,261 +121,258 @@ endif(WIN32)
 
 if(MINIZIP_BUILD_SHARED)
     set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
-    add_library(libminizip SHARED
-        ${LIBMINIZIP_SRCS}
-        ${LIBMINIZIP_HDRS})
+    add_library(libminizip SHARED ${LIBMINIZIP_SRCS} ${LIBMINIZIP_HDRS})
     add_library(MINIZIP::minizip ALIAS libminizip)
-    target_include_directories(libminizip PUBLIC
-        $<BUILD_INTERFACE:${minizip_SOURCE_DIR}>
-        $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
-    target_compile_definitions(libminizip
-        PRIVATE
-            $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
-            $<$<BOOL:${BZIP2_FOUND}>:HAVE_BZIP2=1>
-            $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
-            $<$<BOOL:${HAVE_UNISTD_H}>:HAVE_UNISTD_H=1>
-            $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>
-        PUBLIC
-            $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
+    target_include_directories(
+        libminizip PUBLIC $<BUILD_INTERFACE:${minizip_SOURCE_DIR}>
+                          $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
+    target_compile_definitions(
+        libminizip
+        PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
+                $<$<BOOL:${BZIP2_FOUND}>:HAVE_BZIP2=1>
+                $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
+                $<$<BOOL:${HAVE_UNISTD_H}>:HAVE_UNISTD_H=1>
+                $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>
+        PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
 
     if(NOT CYGWIN)
-        set_target_properties(libminizip PROPERTIES
-            SOVERSION ${minizip_VERSION_MAJOR})
+        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})
+    set_target_properties(
+        libminizip
+        PROPERTIES EXPORT_NAME minizip
+                   OUTPUT_NAME minizip
+                   VERSIOM ${minizip_VERSION}
+                   SOVERSION ${minizip_VERSION_MAJOR})
     target_link_libraries(libminizip PUBLIC ZLIB::ZLIB)
 
-    add_executable(minizip
-        ${MINIZIP_SRCS}
-        ${MINIZIP_HDRS})
-    set_target_properties(minizip PROPERTIES
-        EXPORT_NAME minizip_executable)
-    target_compile_definitions(minizip
-        PRIVATE
-            $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
-            $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>)
+    add_executable(minizip ${MINIZIP_SRCS} ${MINIZIP_HDRS})
+    set_target_properties(minizip PROPERTIES EXPORT_NAME minizip_executable)
+    target_compile_definitions(
+        minizip PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
+                        $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>)
     target_link_libraries(minizip PRIVATE MINIZIP::minizip)
-    add_executable(miniunzip
-        ${MINIUNZIP_SRCS}
-        ${MINIUNZIP_HDRS})
-    set_target_properties(miniunzip PROPERTIES
-        EXPORT_NAME miniunzip_executable)
-    target_compile_definitions(miniunzip
-        PRIVATE
-            $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
-            $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>)
+    add_executable(miniunzip ${MINIUNZIP_SRCS} ${MINIUNZIP_HDRS})
+    set_target_properties(miniunzip PROPERTIES EXPORT_NAME miniunzip_executable)
+    target_compile_definitions(
+        miniunzip PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
+                          $<$<BOOL:NOT:${HAVE_FOPEN64}>: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(libminizipstatic STATIC ${LIBMINIZIP_SRCS} ${LIBMINIZIP_HDRS})
     add_library(MINIZIP::minizipstatic ALIAS libminizipstatic)
-    target_include_directories(libminizipstatic PUBLIC
-        $<BUILD_INTERFACE:${minizip_SOURCE_DIR}>
-        $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
-    target_compile_definitions(libminizipstatic
-        PRIVATE
-            $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
-            $<$<BOOL:${BZIP2_FOUND}>:HAVE_BZIP2=1>
-            $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
-            $<$<BOOL:${HAVE_UNISTD_H}>:HAVE_UNISTD_H=1>
-            $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>
-        PUBLIC
-            $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
-    set_target_properties(libminizipstatic PROPERTIES
-        EXPORT_NAME minizipstatic
-        OUTPUT_NAME minizip${minizip_static_suffix})
+    target_include_directories(
+        libminizipstatic
+        PUBLIC $<BUILD_INTERFACE:${minizip_SOURCE_DIR}>
+               $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
+    target_compile_definitions(
+        libminizipstatic
+        PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
+                $<$<BOOL:${BZIP2_FOUND}>:HAVE_BZIP2=1>
+                $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
+                $<$<BOOL:${HAVE_UNISTD_H}>:HAVE_UNISTD_H=1>
+                $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>
+        PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_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")
+        set_target_properties(libminizipstatic PROPERTIES SUFFIX ".dll.a")
     endif(CYGWIN)
 
     target_link_libraries(libminizipstatic PUBLIC ZLIB::ZLIBSTATIC)
-    add_executable(minizipstatic
-        ${MINIZIP_SRCS}
-        ${MINIZIP_HDRS})
-    set_target_properties(minizipstatic PROPERTIES
-        EXPORT_NAME minizip_static_executable)
-    target_compile_definitions(minizipstatic
-        PRIVATE
-            $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
-            $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>)
+    add_executable(minizipstatic ${MINIZIP_SRCS} ${MINIZIP_HDRS})
+    set_target_properties(minizipstatic PROPERTIES EXPORT_NAME
+                                                   minizip_static_executable)
+    target_compile_definitions(
+        minizipstatic PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
+                              $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>)
     target_link_libraries(minizipstatic PRIVATE MINIZIP::minizipstatic)
-    add_executable(miniunzipstatic
-        ${MINIUNZIP_SRCS}
-        ${MINIUNZIP_HDRS})
-    set_target_properties(miniunzipstatic PROPERTIES
-        EXPORT_NAME miniunzip_static_executable)
-    target_compile_definitions(miniunzipstatic
-        PRIVATE
-            $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
-            $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>)
+    add_executable(miniunzipstatic ${MINIUNZIP_SRCS} ${MINIUNZIP_HDRS})
+    set_target_properties(miniunzipstatic
+                          PROPERTIES EXPORT_NAME miniunzip_static_executable)
+    target_compile_definitions(
+        miniunzipstatic PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
+                                $<$<BOOL:NOT:${HAVE_FOPEN64}>: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
+        install(
+            TARGETS libminizip minizip miniunzip
             COMPONENT Runtime
             EXPORT minizipSharedExport
             RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
             ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
             LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
-        install(EXPORT minizipSharedExport
-                FILE minizip-shared.cmake
-                NAMESPACE MINIZIP::
-                DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/minizip)
+        install(
+            EXPORT minizipSharedExport
+            FILE minizip-shared.cmake
+            NAMESPACE MINIZIP::
+            DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/minizip)
         if(MINIZIP_INSTALL_COMPAT_DLL)
-            install(FILES  $<TARGET_FILE:libminizip>
+            install(
+                FILES $<TARGET_FILE:libminizip>
                 COMPONENT Runtime
                 RENAME libminizip-${minizip_VERSION_MAJOR}.dll
                 DESTINATION "${CMAKE_INSTALL_BINDIR}")
         endif(MINIZIP_INSTALL_COMPAT_DLL)
 
         if(MSVC)
-            install(FILES $<TARGET_PDB_FILE:libminizip>
+            install(
+                FILES $<TARGET_PDB_FILE:libminizip>
                 COMPONENT Runtime
                 DESTINATION ${CMAKE_INSTALL_BINDIR}
                 CONFIGURATIONS Debug OR RelWithDebInfo
-                OPTIONAL
-            )
+                OPTIONAL)
         endif(MSVC)
     endif(MINIZIP_BUILD_SHARED)
 
     if(MINIZIP_BUILD_STATIC)
-        install(TARGETS libminizipstatic
-                COMPONENT Development
-            TARGETS  minizipstatic miniunzipstatic
-                COMPONENT Runtime
+        install(
+            TARGETS libminizipstatic
+            COMPONENT Development
+            TARGETS minizipstatic miniunzipstatic
+            COMPONENT Runtime
             EXPORT minizipStaticExport
             RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
             ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
             LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
-        install(EXPORT minizipStaticExport
-                FILE minizip-static.cmake
-                NAMESPACE MINIZIP::
-                DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/minizip)
+        install(
+            EXPORT minizipStaticExport
+            FILE minizip-static.cmake
+            NAMESPACE MINIZIP::
+            DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/minizip)
     endif(MINIZIP_BUILD_STATIC)
 
-    configure_package_config_file(${minizip_SOURCE_DIR}/minizipConfig.cmake.in
+    configure_package_config_file(
+        ${minizip_SOURCE_DIR}/minizipConfig.cmake.in
         ${minizip_BINARY_DIR}/minizipConfig.cmake
         INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/minizip)
     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(FILES ${LIBMINIZIP_HDRS}
-            COMPONENT Development
-            DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
+    install(FILES ${minizip_BINARY_DIR}/minizipConfig.cmake
+                  ${minizip_BINARY_DIR}/minizipConfigVersion.cmake
+            DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/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
+    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
+        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
+        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
+        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
+        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
+        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)
+                             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")
+                             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
+        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
+        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
+        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
+        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
+        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
+        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)
+                             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)
+                             PROPERTIES FIXTURES_CLEANUP compared_static)
     endif(MINIZIP_BUILD_STATIC)
 
     add_subdirectory(test)
diff --git a/contrib/minizip/minizipConfig.cmake.in b/contrib/minizip/minizipConfig.cmake.in
index 14db08dce..545605354 100644
--- a/contrib/minizip/minizipConfig.cmake.in
+++ b/contrib/minizip/minizipConfig.cmake.in
@@ -15,7 +15,7 @@ if(minizip_FIND_COMPONENTS)
     find_dependency(ZLIB CONFIG COMPONENTS ${minizip_FIND_COMPONENTS})
 
     foreach(_comp ${minizip_FIND_COMPONENTS})
-        if (NOT _comp IN_LIST _MINIZIP_supported_components)
+        if(NOT _comp IN_LIST _MINIZIP_supported_components)
             set(minizip_FOUND False)
             set(minizip_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
         endif(NOT _comp IN_LIST _MINIZIP_supported_components)
diff --git a/contrib/minizip/test/CMakeLists.txt b/contrib/minizip/test/CMakeLists.txt
index 2da5ae144..2f86ee34b 100644
--- a/contrib/minizip/test/CMakeLists.txt
+++ b/contrib/minizip/test/CMakeLists.txt
@@ -1,4 +1,4 @@
-#if we are built from with zlib, use this path's)
+# if we are built from with zlib, use this path's)
 if(DEFINED ZLIB_BUILD_SHARED)
     set(WORK_DIR ${zlib_BINARY_DIR})
     set(inst_setup minizip_minizip_install)
@@ -7,31 +7,30 @@ else(DEFINED ZLIB_BUILD_SHARED)
     set(inst_setup minizip_minizip_install)
     set(ZLIB_ARG "-DZLIB_DIR=${ZLIB_DIR}")
 
-    add_test(NAME minizip_install
-        COMMAND ${CMAKE_COMMAND} --install ${minizip_BINARY_DIR}
-            --prefix ${CMAKE_CURRENT_BINARY_DIR}/test_install
-            --config $<CONFIG>
+    add_test(
+        NAME minizip_install
+        COMMAND ${CMAKE_COMMAND} --install ${minizip_BINARY_DIR} --prefix
+                ${CMAKE_CURRENT_BINARY_DIR}/test_install --config $<CONFIG>
         WORKING_DIRECTORY ${minizip_BINARY_DIR})
 
-    set_tests_properties(minizip_install
-        PROPERTIES
-            FIXTURES_SETUP minizip_install)
+    set_tests_properties(minizip_install PROPERTIES FIXTURES_SETUP
+                                                    minizip_install)
 endif(DEFINED ZLIB_BUILD_SHARED)
 
 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_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
-    @ONLY)
+configure_file(
+    ${CMAKE_CURRENT_SOURCE_DIR}/find_package_test.cmake.in
+    ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test/CMakeLists.txt @ONLY)
 
 configure_file(
     ${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_test.cmake.in
-    ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test/CMakeLists.txt
-    @ONLY)
+    ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test/CMakeLists.txt @ONLY)
 
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_exclude_test.cmake.in
+configure_file(
+    ${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_exclude_test.cmake.in
     ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test/CMakeLists.txt
     @ONLY)
 
@@ -45,83 +44,78 @@ endif(GENERATOR)
 #
 # findpackage_test
 #
-add_test(NAME minizip_find_package_configure
-    COMMAND ${CMAKE_COMMAND}
-        ${PLATFORM}
+add_test(
+    NAME minizip_find_package_configure
+    COMMAND
+        ${CMAKE_COMMAND} ${PLATFORM}
         -B${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build
-        -DCMAKE_BUILD_TYPE=$<CONFIG>
-        -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
+        -DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
         -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-        -DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install
-        ${ZLIB_ARG}
-        --fresh
-        -G "${CMAKE_GENERATOR}"
+        -DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
+        --fresh -G "${CMAKE_GENERATOR}"
         -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
 
-add_test(NAME minizip_find_package_build
-    COMMAND ${CMAKE_COMMAND} --build .
-    --config $<CONFIG>
+add_test(
+    NAME minizip_find_package_build
+    COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
 
-set_tests_properties(minizip_find_package_configure PROPERTIES
-    FIXTURES_REQUIRED ${inst_setup}
-    FIXTURES_SETUP mzfp_config)
+set_tests_properties(
+    minizip_find_package_configure PROPERTIES FIXTURES_REQUIRED ${inst_setup}
+                                              FIXTURES_SETUP mzfp_config)
 
-set_tests_properties(minizip_find_package_build PROPERTIES
-    FIXTURES_REQUIRED mzfp_config)
+set_tests_properties(minizip_find_package_build PROPERTIES FIXTURES_REQUIRED
+                                                           mzfp_config)
 
 #
 # add_subdirectory_test
 #
-add_test(NAME minizip_add_subdirectory_configure
-    COMMAND ${CMAKE_COMMAND}
-    ${PLATFORM}
-    -B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build
-    -DCMAKE_BUILD_TYPE=$<CONFIG>
-    -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-    -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-    -DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install
-    ${ZLIB_ARG}
-    --fresh
-    -G "${CMAKE_GENERATOR}"
-    -S${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test)
-
-add_test(NAME minizip_add_subdirectory_build
-    COMMAND ${CMAKE_COMMAND} --build .
-    --config $<CONFIG>
+add_test(
+    NAME minizip_add_subdirectory_configure
+    COMMAND
+        ${CMAKE_COMMAND} ${PLATFORM}
+        -B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build
+        -DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
+        -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
+        -DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
+        --fresh -G "${CMAKE_GENERATOR}"
+        -S${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test)
+
+add_test(
+    NAME minizip_add_subdirectory_build
+    COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
 
-set_tests_properties(minizip_add_subdirectory_configure PROPERTIES
-    FIXTURES_REQUIRED ${inst_setup}
-    FIXTURES_SETUP mzas_config)
+set_tests_properties(
+    minizip_add_subdirectory_configure
+    PROPERTIES FIXTURES_REQUIRED ${inst_setup} FIXTURES_SETUP mzas_config)
 
-set_tests_properties(minizip_add_subdirectory_build PROPERTIES
-    FIXTURES_REQUIRED mzas_config)
+set_tests_properties(minizip_add_subdirectory_build PROPERTIES FIXTURES_REQUIRED
+                                                               mzas_config)
 
 #
 # add_subdirectory_exclude_test
 #
-add_test(NAME minizip_add_subdirectory_exclude_configure
-    COMMAND ${CMAKE_COMMAND}
-    ${PLATFORM}
-    -B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build
-    -DCMAKE_BUILD_TYPE=$<CONFIG>
-    -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-    -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-    -DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install
-    ${ZLIB_ARG}
-    --fresh
-    -G "${CMAKE_GENERATOR}"
-    -S${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test)
-
-add_test(NAME minizip_add_subdirectory_exclude_build
-    COMMAND ${CMAKE_COMMAND} --build .
-    --config $<CONFIG>
-    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
-
-set_tests_properties(minizip_add_subdirectory_exclude_configure PROPERTIES
-    FIXTURES_REQUIRED ${inst_setup}
-    FIXTURES_SETUP mzasx_config)
-
-set_tests_properties(minizip_add_subdirectory_exclude_build PROPERTIES
-    FIXTURES_REQUIRED mzasx_config)
+add_test(
+    NAME minizip_add_subdirectory_exclude_configure
+    COMMAND
+        ${CMAKE_COMMAND} ${PLATFORM}
+        -B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build
+        -DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
+        -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
+        -DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
+        --fresh -G "${CMAKE_GENERATOR}"
+        -S${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test)
+
+add_test(
+    NAME minizip_add_subdirectory_exclude_build
+    COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
+    WORKING_DIRECTORY
+        ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
+
+set_tests_properties(
+    minizip_add_subdirectory_exclude_configure
+    PROPERTIES FIXTURES_REQUIRED ${inst_setup} FIXTURES_SETUP mzasx_config)
+
+set_tests_properties(minizip_add_subdirectory_exclude_build
+                     PROPERTIES FIXTURES_REQUIRED mzasx_config)
diff --git a/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in b/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in
index f662cda35..8ac16b55f 100644
--- a/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in
+++ b/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in
@@ -1,6 +1,7 @@
 cmake_minimum_required(VERSION 3.12)
 
-project(minizip_add_subdirectory_exclude_from_all
+project(
+    minizip_add_subdirectory_exclude_from_all
     LANGUAGES C
     VERSION @minizip_VERSION@)
 
@@ -9,13 +10,13 @@ option(MINIZIP_BUILD_SHARED "" @MINIZIP_BUILD_SHARED@)
 option(MINIZIP_BUILD_STATIC "" @MINIZIP_BUILD_STATIC@)
 option(MINIZIP_ENABLE_BZIP2 "" @MINIZIP_ENABLE_BZIP2@)
 
-add_subdirectory(@minizip_SOURCE_DIR@ ${CMAKE_CURRENT_BINARY_DIR}/minizip EXCLUDE_FROM_ALL)
+add_subdirectory(@minizip_SOURCE_DIR@ ${CMAKE_CURRENT_BINARY_DIR}/minizip
+                 EXCLUDE_FROM_ALL)
 
 set(MINIZIP_SRCS
     @minizip_SOURCE_DIR@/ioapi.c
     $<$<BOOL:${WIN32}>:@minizip_SOURCE_DIR@/iowin32.c>
-    @minizip_SOURCE_DIR@/minizip.c
-    @minizip_SOURCE_DIR@/zip.c)
+    @minizip_SOURCE_DIR@/minizip.c @minizip_SOURCE_DIR@/zip.c)
 
 if(MINIZIP_BUILD_SHARED)
     add_executable(test_example ${MINIZIP_SRCS})
diff --git a/contrib/minizip/test/add_subdirectory_test.cmake.in b/contrib/minizip/test/add_subdirectory_test.cmake.in
index be5c66409..9d068fb85 100644
--- a/contrib/minizip/test/add_subdirectory_test.cmake.in
+++ b/contrib/minizip/test/add_subdirectory_test.cmake.in
@@ -1,6 +1,7 @@
 cmake_minimum_required(VERSION 3.12)
 
-project(minizip_add_subdirectory_exclude_from_all
+project(
+    minizip_add_subdirectory_exclude_from_all
     LANGUAGES C
     VERSION @minizip_VERSION@)
 
@@ -14,8 +15,7 @@ add_subdirectory(@minizip_SOURCE_DIR@ ${CMAKE_CURRENT_BINARY_DIR}/minizip)
 set(MINIZIP_SRCS
     @minizip_SOURCE_DIR@/ioapi.c
     $<$<BOOL:${WIN32}>:@minizip_SOURCE_DIR@/iowin32.c>
-    @minizip_SOURCE_DIR@/minizip.c
-    @minizip_SOURCE_DIR@/zip.c)
+    @minizip_SOURCE_DIR@/minizip.c @minizip_SOURCE_DIR@/zip.c)
 
 if(MINIZIP_BUILD_SHARED)
     add_executable(test_example ${MINIZIP_SRCS})
diff --git a/contrib/minizip/test/find_package_test.cmake.in b/contrib/minizip/test/find_package_test.cmake.in
index b56b5593b..a2c5fb01a 100644
--- a/contrib/minizip/test/find_package_test.cmake.in
+++ b/contrib/minizip/test/find_package_test.cmake.in
@@ -1,6 +1,7 @@
 cmake_minimum_required(VERSION 3.12)
 
-project(minizip_find_package
+project(
+    minizip_find_package
     LANGUAGES C
     VERSION @minizip_VERSION@)
 
@@ -11,8 +12,7 @@ find_package(minizip ${minizip_VERSION} CONFIG REQUIRED)
 set(MINIZIP_SRCS
     @minizip_SOURCE_DIR@/ioapi.c
     $<$<BOOL:${WIN32}>:@minizip_SOURCE_DIR@/iowin32.c>
-    @minizip_SOURCE_DIR@/minizip.c
-    @minizip_SOURCE_DIR@/zip.c)
+    @minizip_SOURCE_DIR@/minizip.c @minizip_SOURCE_DIR@/zip.c)
 
 if(MINIZIP_BUILD_SHARED)
     add_executable(test_example ${MINIZIP_SRCS})
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index b9bcdfa13..46c07ebf6 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,68 +1,78 @@
-function (ZLIB_findTestEnv testName)
-        set (testEnv "PATH=")
+function(ZLIB_findTestEnv testName)
+    set(testEnv "PATH=")
 
-        if (MSVC OR MINGW)
-                set (separator "\\\;")
-        else()
-                set (separator ":")
-        endif()
+    if(MSVC OR MINGW)
+        set(separator "\\\;")
+    else()
+        set(separator ":")
+    endif()
 
-        string (APPEND testEnv "$<TARGET_FILE_DIR:ZLIB::ZLIB>${separator}")
-        string (APPEND testEnv "$ENV{PATH}")
+    string(APPEND testEnv "$<TARGET_FILE_DIR:ZLIB::ZLIB>${separator}")
+    string(APPEND testEnv "$ENV{PATH}")
 
-        set_tests_properties (${testName} PROPERTIES
-                ENVIRONMENT "${testEnv}"
-        )
+    set_tests_properties(${testName} PROPERTIES ENVIRONMENT "${testEnv}")
 endfunction()
 
 if(ZLIB_BUILD_SHARED)
     add_executable(zlib_example example.c)
     target_link_libraries(zlib_example ZLIB::ZLIB)
-    add_test(NAME zlib_example
-        COMMAND zlib_example)
+    add_test(NAME zlib_example COMMAND zlib_example)
 
     add_executable(minigzip minigzip.c)
-    target_compile_definitions(minigzip
-        PRIVATE
-            $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
+    target_compile_definitions(
+        minigzip PRIVATE $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
     target_link_libraries(minigzip ZLIB::ZLIB)
 
-    if (MSVC OR MSYS OR MINGW OR CYGWIN)
-        ZLIB_findTestEnv (zlib_example)
-    endif (MSVC OR MSYS OR MINGW OR CYGWIN)
+    if(MSVC
+       OR MSYS
+       OR MINGW
+       OR CYGWIN)
+        zlib_findtestenv(zlib_example)
+    endif(
+        MSVC
+        OR MSYS
+        OR MINGW
+        OR CYGWIN)
 
     if(HAVE_OFF64_T)
         add_executable(zlib_example64 example.c)
-        target_compile_definitions(zlib_example64
-            PRIVATE
-                LARGEFILE64_SOURCE=1
-                $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
+        target_compile_definitions(
+            zlib_example64
+            PRIVATE LARGEFILE64_SOURCE=1
+                    $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
         target_link_libraries(zlib_example64 ZLIB::ZLIB)
-        add_test(NAME zlib_example64
-            COMMAND zlib_example64)
-
-        if (MSVC OR MSYS OR MINGW OR CYGWIN)
-            ZLIB_findTestEnv (zlib_example64)
-        endif (MSVC OR MSYS OR MINGW OR CYGWIN)
+        add_test(NAME zlib_example64 COMMAND zlib_example64)
+
+        if(MSVC
+           OR MSYS
+           OR MINGW
+           OR CYGWIN)
+            zlib_findtestenv(zlib_example64)
+        endif(
+            MSVC
+            OR MSYS
+            OR MINGW
+            OR CYGWIN)
     endif(HAVE_OFF64_T)
 endif(ZLIB_BUILD_SHARED)
 
 if(ZLIB_BUILD_STATIC)
     add_executable(zlib_static_example example.c)
     target_link_libraries(zlib_static_example ZLIB::ZLIBSTATIC)
-    target_compile_definitions(zlib_static_example
-        PRIVATE
-            $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
-    add_test(NAME zlib_static_example
-        COMMAND zlib_static_example)
+    target_compile_definitions(
+        zlib_static_example
+        PRIVATE $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
+    add_test(NAME zlib_static_example COMMAND zlib_static_example)
 
     add_executable(static_minigzip minigzip.c)
     target_link_libraries(static_minigzip ZLIB::ZLIBSTATIC)
 
-    if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR
-        ${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
+    if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID} STREQUAL
+                                                "Clang")
         set(CFLAGS_OLD ${CMAKE_C_FLAGS})
-        set({CMAKE_C_FLAGS "" CACHE STRING "" FORCE)
+        set({CMAKE_C_FLAGS
+            ""
+            CACHE STRING "" FORCE)
 
         if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
             find_program(GCOV_EXECUTABLE gcov)
@@ -73,7 +83,7 @@ if(ZLIB_BUILD_STATIC)
             list(APPEND llvm_names llvm-cov)
 
             foreach(ver RANGE 11 99)
-              list(APPEND llvm_names llvm-cov-${ver})
+                list(APPEND llvm_names llvm-cov-${ver})
             endforeach(ver RANGE 11 99)
 
             find_program(GCOV_EXECUTABLE NAMES ${llvm_names})
@@ -84,57 +94,57 @@ if(ZLIB_BUILD_STATIC)
         target_link_libraries(infcover ZLIB::ZLIBSTATIC)
         target_compile_options(infcover PRIVATE -coverage)
         target_link_options(infcover PRIVATE -coverage)
-        target_compile_definitions(infcover
-            PRIVATE
-                $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>: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(${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR
-        ${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
+        target_compile_definitions(
+            infcover PRIVATE $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>: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(${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID}
+                                                   STREQUAL "Clang")
 
     if(HAVE_OFF64_T)
         add_executable(zlib_static_example64 example.c)
-        target_compile_definitions(zlib_static_example64
-            PRIVATE
-                LARGEFILE64_SOURCE=1
-                $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
+        target_compile_definitions(
+            zlib_static_example64
+            PRIVATE LARGEFILE64_SOURCE=1
+                    $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
         target_link_libraries(zlib_static_example64 ZLIB::ZLIBSTATIC)
-        add_test(NAME zlib_static_example64
-            COMMAND zlib_static_example64)
+        add_test(NAME zlib_static_example64 COMMAND zlib_static_example64)
     endif(HAVE_OFF64_T)
 endif(ZLIB_BUILD_STATIC)
 
-add_test(NAME zlib_install
-    COMMAND ${CMAKE_COMMAND} --install ${zlib_BINARY_DIR}
-        --prefix ${CMAKE_CURRENT_BINARY_DIR}/test_install
-        --config $<CONFIG>
+add_test(
+    NAME zlib_install
+    COMMAND ${CMAKE_COMMAND} --install ${zlib_BINARY_DIR} --prefix
+            ${CMAKE_CURRENT_BINARY_DIR}/test_install --config $<CONFIG>
     WORKING_DIRECTORY ${zlib_BINARY_DIR})
 
-set_tests_properties(zlib_install
-    PROPERTIES
-        FIXTURES_SETUP zlib_install)
+set_tests_properties(zlib_install PROPERTIES FIXTURES_SETUP zlib_install)
 
 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_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
-    @ONLY)
+configure_file(
+    ${CMAKE_CURRENT_SOURCE_DIR}/find_package_test.cmake.in
+    ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test/CMakeLists.txt @ONLY)
 
 configure_file(
     ${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_test.cmake.in
-    ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test/CMakeLists.txt
-    @ONLY)
+    ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test/CMakeLists.txt @ONLY)
 
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_exclude_test.cmake.in
+configure_file(
+    ${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_exclude_test.cmake.in
     ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test/CMakeLists.txt
     @ONLY)
 
@@ -147,107 +157,107 @@ endif(GENERATOR)
 #
 # findpackage_test
 #
-add_test(NAME zlib_find_package_configure
-    COMMAND ${CMAKE_COMMAND}
-        ${PLATFORM}
+add_test(
+    NAME zlib_find_package_configure
+    COMMAND
+        ${CMAKE_COMMAND} ${PLATFORM}
         -B${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build
-        -DCMAKE_BUILD_TYPE=$<CONFIG>
-        -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
+        -DCMAKE_BUILD_TYPE=$<CONFIG> -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 zlib_find_package_build
-    COMMAND ${CMAKE_COMMAND} --build .
-    --config $<CONFIG>
+        -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_install --fresh
+        -G "${CMAKE_GENERATOR}" -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
+
+add_test(
+    NAME zlib_find_package_build
+    COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
 
-add_test(NAME zlib_find_package_test
+add_test(
+    NAME zlib_find_package_test
     COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
 
-set_tests_properties(zlib_find_package_configure PROPERTIES
-    FIXTURES_REQUIRED zlib_install
-    FIXTURES_SETUP fp_config)
+set_tests_properties(
+    zlib_find_package_configure PROPERTIES FIXTURES_REQUIRED zlib_install
+                                           FIXTURES_SETUP fp_config)
 
-set_tests_properties(zlib_find_package_build PROPERTIES
-    FIXTURES_REQUIRED fp_config
-    FIXTURES_SETUP fp_build)
+set_tests_properties(
+    zlib_find_package_build PROPERTIES FIXTURES_REQUIRED fp_config
+                                       FIXTURES_SETUP fp_build)
 
-set_tests_properties(zlib_find_package_test PROPERTIES
-    FIXTURES_REQUIRED fp_build
-    ENVIRONMENT CTEST_OUTPUT_ON_FAILURE=1)
+set_tests_properties(
+    zlib_find_package_test PROPERTIES FIXTURES_REQUIRED fp_build ENVIRONMENT
+                                      CTEST_OUTPUT_ON_FAILURE=1)
 
 #
 # add_subdirectory_test
 #
-add_test(NAME zlib_add_subdirectory_configure
-    COMMAND ${CMAKE_COMMAND}
-    ${PLATFORM}
-    -B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build
-    -DCMAKE_BUILD_TYPE=$<CONFIG>
-    -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 zlib_add_subdirectory_build
-    COMMAND ${CMAKE_COMMAND} --build .
-    --config $<CONFIG>
+add_test(
+    NAME zlib_add_subdirectory_configure
+    COMMAND
+        ${CMAKE_COMMAND} ${PLATFORM}
+        -B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build
+        -DCMAKE_BUILD_TYPE=$<CONFIG> -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 zlib_add_subdirectory_build
+    COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
 
-add_test(NAME zlib_add_subdirectory_test
+add_test(
+    NAME zlib_add_subdirectory_test
     COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
 
-set_tests_properties(zlib_add_subdirectory_configure PROPERTIES
-    FIXTURES_REQUIRED zlib_install
-    FIXTURES_SETUP as_config)
+set_tests_properties(
+    zlib_add_subdirectory_configure PROPERTIES FIXTURES_REQUIRED zlib_install
+                                               FIXTURES_SETUP as_config)
 
-set_tests_properties(zlib_add_subdirectory_build PROPERTIES
-    FIXTURES_REQUIRED as_config
-    FIXTURES_SETUP as_build)
+set_tests_properties(
+    zlib_add_subdirectory_build PROPERTIES FIXTURES_REQUIRED as_config
+                                           FIXTURES_SETUP as_build)
 
-set_tests_properties(zlib_add_subdirectory_test PROPERTIES
-    FIXTURES_REQUIRED as_build
-    ENVIRONMENT CTEST_OUTPUT_ON_FAILURE=1)
+set_tests_properties(
+    zlib_add_subdirectory_test PROPERTIES FIXTURES_REQUIRED as_build
+                                          ENVIRONMENT CTEST_OUTPUT_ON_FAILURE=1)
 
 #
 # add_subdirectory_exclude_test
 #
-add_test(NAME zlib_add_subdirectory_exclude_configure
-    COMMAND ${CMAKE_COMMAND}
-    ${PLATFORM}
-    -B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build
-    -DCMAKE_BUILD_TYPE=$<CONFIG>
-    -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 zlib_add_subdirectory_exclude_build
-    COMMAND ${CMAKE_COMMAND} --build .
-    --config $<CONFIG>
-    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
-
-add_test(NAME zlib_add_subdirectory_exclude_test
+add_test(
+    NAME zlib_add_subdirectory_exclude_configure
+    COMMAND
+        ${CMAKE_COMMAND} ${PLATFORM}
+        -B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build
+        -DCMAKE_BUILD_TYPE=$<CONFIG> -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 zlib_add_subdirectory_exclude_build
+    COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
+    WORKING_DIRECTORY
+        ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
+
+add_test(
+    NAME zlib_add_subdirectory_exclude_test
     COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
-    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
+    WORKING_DIRECTORY
+        ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
 
-set_tests_properties(zlib_add_subdirectory_exclude_configure PROPERTIES
-    FIXTURES_REQUIRED zlib_install
-    FIXTURES_SETUP asx_config)
+set_tests_properties(
+    zlib_add_subdirectory_exclude_configure
+    PROPERTIES FIXTURES_REQUIRED zlib_install FIXTURES_SETUP asx_config)
 
-set_tests_properties(zlib_add_subdirectory_exclude_build PROPERTIES
-    FIXTURES_REQUIRED as_config
-    FIXTURES_SETUP asx_build)
+set_tests_properties(
+    zlib_add_subdirectory_exclude_build PROPERTIES FIXTURES_REQUIRED as_config
+                                                   FIXTURES_SETUP asx_build)
 
-set_tests_properties(zlib_add_subdirectory_exclude_test PROPERTIES
-    FIXTURES_REQUIRED asx_build
-    ENVIRONMENT CTEST_OUTPUT_ON_FAILURE=1)
+set_tests_properties(
+    zlib_add_subdirectory_exclude_test
+    PROPERTIES FIXTURES_REQUIRED asx_build ENVIRONMENT
+               CTEST_OUTPUT_ON_FAILURE=1)
diff --git a/test/add_subdirectory_exclude_test.cmake.in b/test/add_subdirectory_exclude_test.cmake.in
index c751a7a5f..c1e8cf46e 100644
--- a/test/add_subdirectory_exclude_test.cmake.in
+++ b/test/add_subdirectory_exclude_test.cmake.in
@@ -1,6 +1,7 @@
 cmake_minimum_required(VERSION 3.10)
 
-project(zlib_find_package_test
+project(
+    zlib_find_package_test
     LANGUAGES C
     VERSION @zlib_VERSION@)
 
@@ -9,7 +10,8 @@ option(ZLIB_BUILD_TESTING "" OFF)
 option(ZLIB_BUILD_SHARED "" @ZLIB_BUILD_SHARED@)
 option(ZLIB_BUILD_STATIC "" @ZLIB_BUILD_STATIC@)
 
-add_subdirectory(@zlib_SOURCE_DIR@ ${CMAKE_CURRENT_BINARY_DIR}/zlib EXCLUDE_FROM_ALL)
+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)
@@ -23,6 +25,5 @@ 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)
+    add_test(NAME zlib_test_example_static COMMAND test_example_static)
 endif(ZLIB_BUILD_STATIC)
diff --git a/test/add_subdirectory_test.cmake.in b/test/add_subdirectory_test.cmake.in
index d5e3a05a8..c7d20f8d1 100644
--- a/test/add_subdirectory_test.cmake.in
+++ b/test/add_subdirectory_test.cmake.in
@@ -1,6 +1,7 @@
 cmake_minimum_required(VERSION 3.10)
 
-project(zlib_find_package_test
+project(
+    zlib_find_package_test
     LANGUAGES C
     VERSION @zlib_VERSION@)
 
@@ -23,6 +24,5 @@ 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)
+    add_test(NAME zlib_test_example_static COMMAND test_example_static)
 endif(@ZLIB_BUILD_STATIC)
diff --git a/test/find_package_test.cmake.in b/test/find_package_test.cmake.in
index 728a1a4f0..afacde5c1 100644
--- a/test/find_package_test.cmake.in
+++ b/test/find_package_test.cmake.in
@@ -1,6 +1,7 @@
 cmake_minimum_required(VERSION 3.10)
 
-project(zlib_find_package_test
+project(
+    zlib_find_package_test
     LANGUAGES C
     VERSION @zlib_VERSION@)
 
@@ -21,6 +22,5 @@ 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)
+    add_test(NAME zlib_test_example_static COMMAND test_example_static)
 endif(ZLIB_BUILD_STATIC)
diff --git a/zlibConfig.cmake.in b/zlibConfig.cmake.in
index d7a849b70..713cac458 100644
--- a/zlibConfig.cmake.in
+++ b/zlibConfig.cmake.in
@@ -12,7 +12,7 @@ endif(@ZLIB_BUILD_STATIC@)
 
 if(ZLIB_FIND_COMPONENTS)
     foreach(_comp ${ZLIB_FIND_COMPONENTS})
-        if (NOT _comp IN_LIST _ZLIB_supported_components)
+        if(NOT _comp IN_LIST _ZLIB_supported_components)
             set(ZLIB_FOUND False)
             set(ZLIB_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
         endif(NOT _comp IN_LIST _ZLIB_supported_components)

From 6925d39b5005ecc6b01e34f3b59aa79d72de900e Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Fri, 3 Jan 2025 09:59:13 +0100
Subject: [PATCH 101/128] CMake: Fix typo.

---
 contrib/minizip/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/minizip/CMakeLists.txt b/contrib/minizip/CMakeLists.txt
index f252002d0..38d870ff4 100644
--- a/contrib/minizip/CMakeLists.txt
+++ b/contrib/minizip/CMakeLists.txt
@@ -144,7 +144,7 @@ if(MINIZIP_BUILD_SHARED)
         libminizip
         PROPERTIES EXPORT_NAME minizip
                    OUTPUT_NAME minizip
-                   VERSIOM ${minizip_VERSION}
+                   VERSION ${minizip_VERSION}
                    SOVERSION ${minizip_VERSION_MAJOR})
     target_link_libraries(libminizip PUBLIC ZLIB::ZLIB)
 

From 734f974753571310fdf6c73ba38f17362dcf71ba Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 22 Jan 2025 17:04:43 +0100
Subject: [PATCH 102/128] CMake: Re-enable Cygwin tests without Ninja.

---
 .github/workflows/msys-cygwin.yml | 62 +++++++++++++++----------------
 1 file changed, 30 insertions(+), 32 deletions(-)

diff --git a/.github/workflows/msys-cygwin.yml b/.github/workflows/msys-cygwin.yml
index 276959b30..4f5018c79 100644
--- a/.github/workflows/msys-cygwin.yml
+++ b/.github/workflows/msys-cygwin.yml
@@ -40,35 +40,33 @@ jobs:
     - name: Run tests
       run: ctest --output-on-failure --test-dir build -C Release
 
-#  cygwin:
-#    strategy:
-#      fail-fast: false
-#    runs-on: windows-latest
-#    defaults:
-#      run:
-#        shell: C:\cygwin\bin\bash.exe --login -o igncr '{0}'
-#    name: Cygwin
-#    steps:
-#    - name: Checkout
-#      uses: actions/checkout@v4
-#      with:
-#        fetch-depth: 0
-#    - name: Setup cygwin
-#      uses: cygwin/cygwin-install-action@master
-#      with:
-#        packages: >-
-#          cmake
-#          cygwin-devel
-#          gcc-core
-#          gcc-g++
-#          ninja
-#    - name: Configure
-#      run: |
-#        cmake /cygdrive/d/a/zlib/zlib \
-#          -B build \
-#          -DCMAKE_BUILD_TYPE=Release \
-#          -G Ninja
-#    - name: Build
-#      run: cmake --build build --config Release
-#    - name: Run tests
-#      run: ctest --output-on-failure --test-dir build -C Release
+  cygwin:
+    strategy:
+      fail-fast: false
+    runs-on: windows-latest
+    defaults:
+      run:
+        shell: C:\cygwin\bin\bash.exe --login -o igncr '{0}'
+    name: Cygwin
+    steps:
+    - name: Checkout
+      uses: actions/checkout@v4
+      with:
+        fetch-depth: 0
+    - name: Setup cygwin
+      uses: cygwin/cygwin-install-action@master
+      with:
+        packages: >-
+          cmake
+          cygwin-devel
+          gcc-core
+          gcc-g++
+    - name: Configure
+      run: |
+        cmake /cygdrive/d/a/zlib/zlib \
+          -B build \
+          -DCMAKE_BUILD_TYPE=Release
+    - name: Build
+      run: cmake --build build --config Release
+    - name: Run tests
+      run: ctest --output-on-failure --test-dir build -C Release

From 213998f2b0dbe21b50f18c242ddb43b34e79b75f Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 22 Jan 2025 17:05:05 +0100
Subject: [PATCH 103/128] CMake: Include bzip2 in the interface.

---
 contrib/minizip/CMakeLists.txt         | 17 +++++++++++------
 contrib/minizip/minizipConfig.cmake.in |  6 +++++-
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/contrib/minizip/CMakeLists.txt b/contrib/minizip/CMakeLists.txt
index 38d870ff4..b0ed62c33 100644
--- a/contrib/minizip/CMakeLists.txt
+++ b/contrib/minizip/CMakeLists.txt
@@ -129,11 +129,11 @@ if(MINIZIP_BUILD_SHARED)
     target_compile_definitions(
         libminizip
         PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
-                $<$<BOOL:${BZIP2_FOUND}>:HAVE_BZIP2=1>
                 $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
                 $<$<BOOL:${HAVE_UNISTD_H}>:HAVE_UNISTD_H=1>
                 $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>
-        PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
+        PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>
+                $<$<BOOL:${BZIP2_FOUND}>:HAVE_BZIP2=1>)
 
     if(NOT CYGWIN)
         set_target_properties(libminizip PROPERTIES SOVERSION
@@ -146,7 +146,10 @@ if(MINIZIP_BUILD_SHARED)
                    OUTPUT_NAME minizip
                    VERSION ${minizip_VERSION}
                    SOVERSION ${minizip_VERSION_MAJOR})
-    target_link_libraries(libminizip PUBLIC ZLIB::ZLIB)
+
+    target_link_libraries(libminizip
+        PUBLIC ZLIB::ZLIB
+            $<$<BOOL:${BZIP2_FOUND}>:BZip2::BZip2>)
 
     add_executable(minizip ${MINIZIP_SRCS} ${MINIZIP_HDRS})
     set_target_properties(minizip PROPERTIES EXPORT_NAME minizip_executable)
@@ -172,11 +175,11 @@ if(MINIZIP_BUILD_STATIC)
     target_compile_definitions(
         libminizipstatic
         PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
-                $<$<BOOL:${BZIP2_FOUND}>:HAVE_BZIP2=1>
                 $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
                 $<$<BOOL:${HAVE_UNISTD_H}>:HAVE_UNISTD_H=1>
                 $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>
-        PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
+        PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>
+                $<$<BOOL:${BZIP2_FOUND}>:HAVE_BZIP2=1>)
     set_target_properties(
         libminizipstatic PROPERTIES EXPORT_NAME minizipstatic
                                     OUTPUT_NAME minizip${minizip_static_suffix})
@@ -185,7 +188,9 @@ if(MINIZIP_BUILD_STATIC)
         set_target_properties(libminizipstatic PROPERTIES SUFFIX ".dll.a")
     endif(CYGWIN)
 
-    target_link_libraries(libminizipstatic PUBLIC ZLIB::ZLIBSTATIC)
+    target_link_libraries(libminizipstatic PUBLIC ZLIB::ZLIBSTATIC
+        $<$<BOOL:${BZIP2_FOUND}>:BZip2::BZip2>)
+
     add_executable(minizipstatic ${MINIZIP_SRCS} ${MINIZIP_HDRS})
     set_target_properties(minizipstatic PROPERTIES EXPORT_NAME
                                                    minizip_static_executable)
diff --git a/contrib/minizip/minizipConfig.cmake.in b/contrib/minizip/minizipConfig.cmake.in
index 545605354..88ea0a080 100644
--- a/contrib/minizip/minizipConfig.cmake.in
+++ b/contrib/minizip/minizipConfig.cmake.in
@@ -1,8 +1,8 @@
 @PACKAGE_INIT@
 
-set(MINIZIP_ENABLE_BZIP2 @MINIZIP_ENABLE_BZIP2@)
 set(_minizip_supported_components "")
 include(CMakeFindDependencyMacro)
+
 if(@MINIZIP_BUILD_SHARED@)
     list(APPEND _minizip_supported_components shared)
 endif(@MINIZIP_BUILD_SHARED@)
@@ -11,6 +11,10 @@ if(@MINIZIP_BUILD_STATIC@)
     list(APPEND _minizip_supported_components static)
 endif(@MINIZIP_BUILD_STATIC@)
 
+if(@MINIZIP_ENABLE_BZIP2@)
+    find_dependency(BZip2)
+endif(@MINIZIP_ENABLE_BZIP2@)
+
 if(minizip_FIND_COMPONENTS)
     find_dependency(ZLIB CONFIG COMPONENTS ${minizip_FIND_COMPONENTS})
 

From 6c224f159e6d940f775c017b1bc354d39d74ee48 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 22 Jan 2025 17:24:17 +0100
Subject: [PATCH 104/128] CMake: Change README-cmake to README-cmake.md with
 formatting.

Per @ClausKlein suggestion.
---
 README-cmake.md | 83 +++++++++++++++++++++++++++++++++++++++++++++++++
 README.cmake    | 76 --------------------------------------------
 2 files changed, 83 insertions(+), 76 deletions(-)
 create mode 100644 README-cmake.md
 delete mode 100644 README.cmake

diff --git a/README-cmake.md b/README-cmake.md
new file mode 100644
index 000000000..7258f9cad
--- /dev/null
+++ b/README-cmake.md
@@ -0,0 +1,83 @@
+# For building with cmake at least version 3.12 (minizip 3.12) is needed
+
+In most cases the usual
+
+    cmake -S . -B build -D CMAKE_BUILD_TYPE=Release
+
+will create everything you need, however if you want something off default you can adjust several options fit your needs.
+Every option is list below (excluding the cmake-standard options), they can be set via cmake-gui or on cmdline with
+
+    -D<option>=ON/OFF
+
+## ZLIB-options with defaults ##
+
+    ZLIB_BUILD_TESTING=ON -- Enable Zlib Examples as tests
+
+    ZLIB_BUILD_SHARED=ON -- Enable building zlib shared library
+
+    ZLIB_BUILD_STATIC=ON -- Enable building zlib static library
+
+    ZLIB_BUILD_MINIZIP=ON -- Enable building libminizip contrib library
+
+If this option is turned on, additional options are available from minizip (see below)
+
+    ZLIB_INSTALL=ON -- Enable installation of zlib
+
+    ZLIB_PREFIX=OFF -- prefix for all types and library functions, see zconf.h.in
+
+    ZLIB_INSTALL_COMPAT_DLL=ON -- Install a copy as zlib1.dll
+
+This option is only on windows available and may/will be turned off and removed somewhen in the future.
+If you rely cmake for finding and using zlib, this can be turned off, as `zlib1.dll` will never be used.
+
+## minizip-options with defaults ##
+
+    MINIZIP_BUILD_SHARED=ON -- Enable building minizip shared library
+
+    MINIZIP_BUILD_STATIC=ON -- Enable building minizip static library
+
+    MINIZIP_BUILD_TESTING=ON -- Enable testing of minizip
+
+    MINIZIP_ENABLE_BZIP2=ON -- Build minizip withj bzip2 support
+
+A usable installation of bzip2 is needed or config will fail. Turn this option of in this case.
+
+    MINIZIP_INSTALL=ON -- Enable installation of minizip
+
+    MINIZIP_INSTALL_COMPAT_DLL=ON -- Install a copy as libminizip-1.dll
+
+This option is only available on mingw as they tend to name this lib different. Maybe this will also be
+removed in the future as. If you rely cmake for finding and using zlib, this can be turned off, as
+the other file will never be used.
+
+## Using the libs ##
+
+To pull in what you need it's enough to just write
+
+    find_package(ZLIB CONFIG)
+
+or
+
+    find_package(minizip CONFIG)
+
+in your CMakeLists.txt, however it is advised to specify what you really want via:
+
+    find_package(ZLIB CONFIG COMPONENTS shared static REQUIRED)
+
+or
+
+    find_package(minizip CONFIG COMPONENTS shared static REQUIRED)
+
+As it's possible to only build the shared or the static lib, you can make sure that everything you need
+is found. If no COMPONENTS are requested, everything that is found will satisfy your request. If the
+libraries are optional in you project, you can omit the REQUIRED and check yourself if the targets you
+want to link against are created.
+
+When you search for minizip, it will search zlib for you, so only one of both is needed.
+
+## Imported targets ##
+
+When found the following targets are created for you:
+
+    ZLIB::ZLIB and ZLIB::ZLIBSTATIC -- for zlib
+    MINIZIP::minizip and MINIZIP::minizipstatic -- for minizip
diff --git a/README.cmake b/README.cmake
deleted file mode 100644
index 96d492c96..000000000
--- a/README.cmake
+++ /dev/null
@@ -1,76 +0,0 @@
-For building with cmake at least version 3.10 (minizip 3.12) is needed
-
-In most cases the usual "mkdir build && cd build && cmake .." will create everything you need, however
-if you want something off default you can adjust several options fit your needs. Every option is
-list below (excluding the cmake-standard options), they can be set via cmake-gui or on cmdline with
-
-	-D<option>=ON/OFF
-
-## ZLIB-options with defaults ##
-
-ZLIB_BUILD_TESTING=ON -- Enable Zlib Examples as tests
-
-ZLIB_BUILD_SHARED=ON -- Enable building zlib shared library
-
-ZLIB_BUILD_STATIC=ON -- Enable building zlib static library
-
-ZLIB_BUILD_MINIZIP=ON -- Enable building libminizip contrib library
-If this option is turned on, additional options are available from minizip (see below)
-
-ZLIB_INSTALL=ON -- Enable installation of zlib
-
-ZLIB_PREFIX=OFF -- prefix for all types and library functions, see zconf.h.in
-
-ZLIB_INSTALL_COMPAT_DLL=ON -- Install a copy as zlib1.dll
-This option is only on windows available and may/will be turned off and removed somewhen in the future.
-If you rely cmake for finding and using zlib, this can be turned off, as zlib1.dll will never be used.
-
-## minizip-options with defaults ##
-
-MINIZIP_BUILD_SHARED=ON Enable building minizip shared library
-
-MINIZIP_BUILD_STATIC=ON Enable building minizip static library
-
-MINIZIP_BUILD_TESTING=ON Enable testing of minizip
-
-MINIZIP_ENABLE_BZIP2=ON Build minizip withj bzip2 support
-A usable installation of bzip2 is needed or config will fail. Turn this option of in this case.
-
-MINIZIP_INSTALL=ON Enable installation of minizip
-
-MINIZIP_INSTALL_COMPAT_DLL=ON Install a copy as libminizip-1.dll
-This option is only available on mingw as they tend to name this lib different. Maybe this will also be
-removed in the future as. If you rely cmake for finding and using zlib, this can be turned off, as
-the other file will never be used.
-
-## Using the libs ##
-
-To pull in what you need it's enough to just write
-
-	find_package(ZLIB CONFIG)
-or
-	find_package(minizip CONFIG)
-
-in your CMakeLists.txt, however it is advised to specify what you really want via:
-
-	find_package(ZLIB CONFIG COMPONENTS shared static REQUIRED)
-or
-	find_package(minizip CONFIG COMPONENTS shared static REQUIRED)
-
-As it's possible to only build the shared or the static lib, you can make sure that everything you need
-is found. If no COMPONENTS are requested, everything that is found will satisfy your request. If the
-libraries are optional in you project, you can omit the REQUIRED and check yourself if the targets you
-want to link against are created.
-
-When you search for minizip, it will search zlib for you, so only one of both is needed.
-
-## Imported targets ##
-When found the following targets are created for you:
-
-ZLIB::ZLIB and ZLIB:ZLIBSTATIC for zlib
-MINIZIP::minizip and MINIZIP::minizipstatic for minizip
-
-In addition a var called  MINIZIP_ENABLE_BZIP2 is exported so you can check if you got a bzip2 enabled
-version of the lib. As linking against libbz2 is only needed if you use functions from that set, it's
-no hard dep and you have to make sure a working bzip2-installation is found and linked in your binary.
-

From 03449d49ba812aac996dd4895d309cc204f9b704 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 22 Jan 2025 17:27:16 +0100
Subject: [PATCH 105/128] CMake: Re-enable testing with bzip2.

---
 .github/workflows/cmake.yml       | 2 +-
 .github/workflows/msys-cygwin.yml | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml
index 1b6171158..51f8ba6c0 100644
--- a/.github/workflows/cmake.yml
+++ b/.github/workflows/cmake.yml
@@ -76,7 +76,7 @@ jobs:
         choco install --no-progress ninja ${{ matrix.packages }}
 
     - name: Generate project files
-      run: cmake -S . -B ../build ${{ matrix.cmake-args }} -D CMAKE_BUILD_TYPE=${{ matrix.build-config || 'Release' }} -DZLIB_BUILD_MINIZIP=ON -DMINIZIP_ENABLE_BZIP2=OFF
+      run: cmake -S . -B ../build ${{ matrix.cmake-args }} -D CMAKE_BUILD_TYPE=${{ matrix.build-config || 'Release' }} -DZLIB_BUILD_MINIZIP=ON -DMINIZIP_ENABLE_BZIP2=ON
       env:
         CC: ${{ matrix.compiler }}
         CFLAGS: ${{ matrix.cflags }}
diff --git a/.github/workflows/msys-cygwin.yml b/.github/workflows/msys-cygwin.yml
index 4f5018c79..7e00c00fc 100644
--- a/.github/workflows/msys-cygwin.yml
+++ b/.github/workflows/msys-cygwin.yml
@@ -34,7 +34,8 @@ jobs:
           -S . \
           -B build \
           -DCMAKE_VERBOSE_MAKEFILE=ON \
-          -DCMAKE_BUILD_TYPE=Release
+          -DCMAKE_BUILD_TYPE=Release \
+          -DMINIZIP_ENABLE_BZIP2=ON
     - name: Build
       run: cmake --build build --config Release
     - name: Run tests
@@ -65,7 +66,8 @@ jobs:
       run: |
         cmake /cygdrive/d/a/zlib/zlib \
           -B build \
-          -DCMAKE_BUILD_TYPE=Release
+          -DCMAKE_BUILD_TYPE=Release \
+          -DMINIZIP_ENABLE_BZIP2=ON
     - name: Build
       run: cmake --build build --config Release
     - name: Run tests

From 1cac365fe48f7191658181979db18247d0528206 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 22 Jan 2025 17:27:28 +0100
Subject: [PATCH 106/128] CMake: Add make to Cygwin.

---
 .github/workflows/msys-cygwin.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.github/workflows/msys-cygwin.yml b/.github/workflows/msys-cygwin.yml
index 7e00c00fc..0bc1729ae 100644
--- a/.github/workflows/msys-cygwin.yml
+++ b/.github/workflows/msys-cygwin.yml
@@ -62,6 +62,7 @@ jobs:
           cygwin-devel
           gcc-core
           gcc-g++
+          make
     - name: Configure
       run: |
         cmake /cygdrive/d/a/zlib/zlib \

From 63ded6faaf16bf98536003e9c8c9d485a84e50c3 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 22 Jan 2025 17:52:59 +0100
Subject: [PATCH 107/128] CMake: Install missing bzip2 in workflow.

---
 .github/workflows/cmake.yml | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml
index 51f8ba6c0..fcd69a5a3 100644
--- a/.github/workflows/cmake.yml
+++ b/.github/workflows/cmake.yml
@@ -73,8 +73,12 @@ jobs:
     - name: Install packages (Windows)
       if: runner.os == 'Windows'
       run: |
-        choco install --no-progress ninja ${{ matrix.packages }}
+        choco install --no-progress ninja bzip2
 
+    - name: Install packages (Windows)
+      if: runner.os == 'Ubuntu'
+      run: |
+        apt install libbz2-dev
     - name: Generate project files
       run: cmake -S . -B ../build ${{ matrix.cmake-args }} -D CMAKE_BUILD_TYPE=${{ matrix.build-config || 'Release' }} -DZLIB_BUILD_MINIZIP=ON -DMINIZIP_ENABLE_BZIP2=ON
       env:

From c6d44927c5d7dfa3abba739f79050c34215b754e Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 22 Jan 2025 17:53:17 +0100
Subject: [PATCH 108/128] CMake: Switch from make back to ninja.

Limit to one job.
---
 .github/workflows/msys-cygwin.yml | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/msys-cygwin.yml b/.github/workflows/msys-cygwin.yml
index 0bc1729ae..1bfd9369a 100644
--- a/.github/workflows/msys-cygwin.yml
+++ b/.github/workflows/msys-cygwin.yml
@@ -62,14 +62,16 @@ jobs:
           cygwin-devel
           gcc-core
           gcc-g++
-          make
+          ninja
     - name: Configure
       run: |
         cmake /cygdrive/d/a/zlib/zlib \
           -B build \
           -DCMAKE_BUILD_TYPE=Release \
-          -DMINIZIP_ENABLE_BZIP2=ON
+          -DZLIB_BUILD_MINIZIP=ON \
+          -DMINIZIP_ENABLE_BZIP2=ON \
+          -G Ninja
     - name: Build
-      run: cmake --build build --config Release
+      run: cmake --build build --config Release -v -j1
     - name: Run tests
       run: ctest --output-on-failure --test-dir build -C Release

From 5760ba15706b01d9b9d6e6e4806de0eb5b7b2ab5 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 22 Jan 2025 18:02:09 +0100
Subject: [PATCH 109/128] CMake: Correct runner.os to Linux.

---
 .github/workflows/cmake.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml
index fcd69a5a3..f0f293a75 100644
--- a/.github/workflows/cmake.yml
+++ b/.github/workflows/cmake.yml
@@ -75,8 +75,8 @@ jobs:
       run: |
         choco install --no-progress ninja bzip2
 
-    - name: Install packages (Windows)
-      if: runner.os == 'Ubuntu'
+    - name: Install packages (Linux)
+      if: runner.os == 'Linux'
       run: |
         apt install libbz2-dev
     - name: Generate project files

From 05051d236bd554a71f9f39371f8cbe19c14e30f7 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 22 Jan 2025 18:05:59 +0100
Subject: [PATCH 110/128] CMake: Install bzip2 on Cygwin in workflow.

---
 .github/workflows/msys-cygwin.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.github/workflows/msys-cygwin.yml b/.github/workflows/msys-cygwin.yml
index 1bfd9369a..e32551686 100644
--- a/.github/workflows/msys-cygwin.yml
+++ b/.github/workflows/msys-cygwin.yml
@@ -58,6 +58,7 @@ jobs:
       uses: cygwin/cygwin-install-action@master
       with:
         packages: >-
+          bzip2
           cmake
           cygwin-devel
           gcc-core

From 6c2ab4ddc6e7f0bce7764a470f4917607d3fd107 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 22 Jan 2025 18:49:43 +0100
Subject: [PATCH 111/128] CMake: Do not test with bzip2 on Windows or Cygwin.

---
 .github/workflows/cmake.yml       | 14 +++++++++++---
 .github/workflows/msys-cygwin.yml |  3 +--
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml
index f0f293a75..a25a38776 100644
--- a/.github/workflows/cmake.yml
+++ b/.github/workflows/cmake.yml
@@ -13,18 +13,21 @@ jobs:
             compiler: gcc
             cflags: -Wall -Wextra
             pkgtgt: package package_source
+            cmake-args: -DMINIZIP_ENABLE_BZIP2=ON
 
           - name: Ubuntu GCC -O3
             os: ubuntu-latest
             compiler: gcc
             cflags: -O3 -Wall -Wextra
             pkgtgt: package package_source
+            cmake-args: -DMINIZIP_ENABLE_BZIP2=ON
 
           - name: Ubuntu Clang
             os: ubuntu-latest
             compiler: clang
             cflags: -Wall -Wextra
             pkgtgt: package package_source
+            cmake-args: -DMINIZIP_ENABLE_BZIP2=ON
 
           - name: Ubuntu Clang Debug
             os: ubuntu-latest
@@ -32,6 +35,7 @@ jobs:
             cflags: -Wall -Wextra
             build-config: Debug
             pkgtgt: package package_source
+            cmake-args: -DMINIZIP_ENABLE_BZIP2=ON
 
           - name: Windows MSVC Win32
             os: windows-latest
@@ -46,6 +50,7 @@ jobs:
             cflags: /W3
             cmake-args: -A x64
             pkgtgt: PACKAGE
+            cmake-args: -DMINIZIP_ENABLE_BZIP2=OFF
 
           - name: Windows GCC
             os: windows-latest
@@ -53,18 +58,21 @@ jobs:
             cflags: -Wall -Wextra
             cmake-args: -G Ninja
             pkgtgt: package
+            cmake-args: -DMINIZIP_ENABLE_BZIP2=OFF
 
           - name: macOS Clang
             os: macos-latest
             compiler: clang
             cflags: -Wall -Wextra
             pkgtgt: package
+            cmake-args: -DMINIZIP_ENABLE_BZIP2=ON
 
           - name: macOS GCC
             os: macos-latest
             compiler: gcc-12
             cflags: -Wall -Wextra
             pkgtgt: package
+            cmake-args: -DMINIZIP_ENABLE_BZIP2=ON
 
     steps:
     - name: Checkout repository
@@ -73,14 +81,14 @@ jobs:
     - name: Install packages (Windows)
       if: runner.os == 'Windows'
       run: |
-        choco install --no-progress ninja bzip2
+        choco install --no-progress ninja
 
     - name: Install packages (Linux)
       if: runner.os == 'Linux'
       run: |
-        apt install libbz2-dev
+        sudo apt install libbz2-dev
     - name: Generate project files
-      run: cmake -S . -B ../build ${{ matrix.cmake-args }} -D CMAKE_BUILD_TYPE=${{ matrix.build-config || 'Release' }} -DZLIB_BUILD_MINIZIP=ON -DMINIZIP_ENABLE_BZIP2=ON
+      run: cmake -S . -B ../build ${{ matrix.cmake-args }} -D CMAKE_BUILD_TYPE=${{ matrix.build-config || 'Release' }} -DZLIB_BUILD_MINIZIP=ON
       env:
         CC: ${{ matrix.compiler }}
         CFLAGS: ${{ matrix.cflags }}
diff --git a/.github/workflows/msys-cygwin.yml b/.github/workflows/msys-cygwin.yml
index e32551686..ef2593f2e 100644
--- a/.github/workflows/msys-cygwin.yml
+++ b/.github/workflows/msys-cygwin.yml
@@ -58,7 +58,6 @@ jobs:
       uses: cygwin/cygwin-install-action@master
       with:
         packages: >-
-          bzip2
           cmake
           cygwin-devel
           gcc-core
@@ -70,7 +69,7 @@ jobs:
           -B build \
           -DCMAKE_BUILD_TYPE=Release \
           -DZLIB_BUILD_MINIZIP=ON \
-          -DMINIZIP_ENABLE_BZIP2=ON \
+          -DMINIZIP_ENABLE_BZIP2=OFF
           -G Ninja
     - name: Build
       run: cmake --build build --config Release -v -j1

From 5a31e529bc974c0409bfd75f71fe1101a3e581f7 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 22 Jan 2025 19:01:14 +0100
Subject: [PATCH 112/128] CMake: Add the tested version of cmake (3.31).

Per @ClausKlein suggestion.
---
 CMakeLists.txt                                              | 2 +-
 contrib/minizip/CMakeLists.txt                              | 2 +-
 contrib/minizip/test/add_subdirectory_exclude_test.cmake.in | 2 +-
 contrib/minizip/test/add_subdirectory_test.cmake.in         | 2 +-
 contrib/minizip/test/find_package_test.cmake.in             | 2 +-
 test/add_subdirectory_exclude_test.cmake.in                 | 2 +-
 test/add_subdirectory_test.cmake.in                         | 2 +-
 test/find_package_test.cmake.in                             | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 705409124..bcff93cdb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.12)
+cmake_minimum_required(VERSION 3.12 ... 3.31)
 
 project(
     zlib
diff --git a/contrib/minizip/CMakeLists.txt b/contrib/minizip/CMakeLists.txt
index b0ed62c33..de0fdf719 100644
--- a/contrib/minizip/CMakeLists.txt
+++ b/contrib/minizip/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.12)
+cmake_minimum_required(VERSION 3.12 ... 3.31)
 
 project(
     minizip
diff --git a/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in b/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in
index 8ac16b55f..c512afd46 100644
--- a/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in
+++ b/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.12)
+cmake_minimum_required(VERSION 3.12 ... 3.31)
 
 project(
     minizip_add_subdirectory_exclude_from_all
diff --git a/contrib/minizip/test/add_subdirectory_test.cmake.in b/contrib/minizip/test/add_subdirectory_test.cmake.in
index 9d068fb85..ffadd8a6c 100644
--- a/contrib/minizip/test/add_subdirectory_test.cmake.in
+++ b/contrib/minizip/test/add_subdirectory_test.cmake.in
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.12)
+cmake_minimum_required(VERSION 3.12 ... 3.31)
 
 project(
     minizip_add_subdirectory_exclude_from_all
diff --git a/contrib/minizip/test/find_package_test.cmake.in b/contrib/minizip/test/find_package_test.cmake.in
index a2c5fb01a..6803ed4c1 100644
--- a/contrib/minizip/test/find_package_test.cmake.in
+++ b/contrib/minizip/test/find_package_test.cmake.in
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.12)
+cmake_minimum_required(VERSION 3.12 ... 3.31)
 
 project(
     minizip_find_package
diff --git a/test/add_subdirectory_exclude_test.cmake.in b/test/add_subdirectory_exclude_test.cmake.in
index c1e8cf46e..7b0934e3b 100644
--- a/test/add_subdirectory_exclude_test.cmake.in
+++ b/test/add_subdirectory_exclude_test.cmake.in
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.10)
+cmake_minimum_required(VERSION 3.12 ... 3.31)
 
 project(
     zlib_find_package_test
diff --git a/test/add_subdirectory_test.cmake.in b/test/add_subdirectory_test.cmake.in
index c7d20f8d1..0d3db212c 100644
--- a/test/add_subdirectory_test.cmake.in
+++ b/test/add_subdirectory_test.cmake.in
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.10)
+cmake_minimum_required(VERSION 3.12 ... 3.31)
 
 project(
     zlib_find_package_test
diff --git a/test/find_package_test.cmake.in b/test/find_package_test.cmake.in
index afacde5c1..fbe0078a5 100644
--- a/test/find_package_test.cmake.in
+++ b/test/find_package_test.cmake.in
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.10)
+cmake_minimum_required(VERSION 3.12 ... 3.31)
 
 project(
     zlib_find_package_test

From cdb3ab194cf27c380779d4a59f9f824f03a34dfb Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 22 Jan 2025 19:48:48 +0100
Subject: [PATCH 113/128] CMake: Correct workflow options to disable bzip2 on
 Windows.

Note that Vollstrecker hates yaml.
---
 .github/workflows/cmake.yml | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml
index a25a38776..25a3b8124 100644
--- a/.github/workflows/cmake.yml
+++ b/.github/workflows/cmake.yml
@@ -48,17 +48,15 @@ jobs:
             os: windows-latest
             compiler: cl
             cflags: /W3
-            cmake-args: -A x64
+            cmake-args: -A x64 -DMINIZIP_ENABLE_BZIP2=OFF
             pkgtgt: PACKAGE
-            cmake-args: -DMINIZIP_ENABLE_BZIP2=OFF
 
           - name: Windows GCC
             os: windows-latest
             compiler: gcc
             cflags: -Wall -Wextra
-            cmake-args: -G Ninja
+            cmake-args: -G Ninja -DMINIZIP_ENABLE_BZIP2=OFF
             pkgtgt: package
-            cmake-args: -DMINIZIP_ENABLE_BZIP2=OFF
 
           - name: macOS Clang
             os: macos-latest

From 2c62f8885c073b67d828ea89ffd39e1556d52bdc Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 22 Jan 2025 19:57:19 +0100
Subject: [PATCH 114/128] CMake: Clean up spaces in required versions.

---
 CMakeLists.txt                                              | 2 +-
 contrib/minizip/CMakeLists.txt                              | 2 +-
 contrib/minizip/test/add_subdirectory_exclude_test.cmake.in | 2 +-
 contrib/minizip/test/add_subdirectory_test.cmake.in         | 2 +-
 contrib/minizip/test/find_package_test.cmake.in             | 2 +-
 test/add_subdirectory_exclude_test.cmake.in                 | 2 +-
 test/add_subdirectory_test.cmake.in                         | 2 +-
 test/find_package_test.cmake.in                             | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index bcff93cdb..d963e7c04 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.12 ... 3.31)
+cmake_minimum_required(VERSION 3.12...3.31)
 
 project(
     zlib
diff --git a/contrib/minizip/CMakeLists.txt b/contrib/minizip/CMakeLists.txt
index de0fdf719..1109585cb 100644
--- a/contrib/minizip/CMakeLists.txt
+++ b/contrib/minizip/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.12 ... 3.31)
+cmake_minimum_required(VERSION 3.12...3.31)
 
 project(
     minizip
diff --git a/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in b/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in
index c512afd46..2b9fc68f3 100644
--- a/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in
+++ b/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.12 ... 3.31)
+cmake_minimum_required(VERSION 3.12...3.31)
 
 project(
     minizip_add_subdirectory_exclude_from_all
diff --git a/contrib/minizip/test/add_subdirectory_test.cmake.in b/contrib/minizip/test/add_subdirectory_test.cmake.in
index ffadd8a6c..ca49895ba 100644
--- a/contrib/minizip/test/add_subdirectory_test.cmake.in
+++ b/contrib/minizip/test/add_subdirectory_test.cmake.in
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.12 ... 3.31)
+cmake_minimum_required(VERSION 3.12...3.31)
 
 project(
     minizip_add_subdirectory_exclude_from_all
diff --git a/contrib/minizip/test/find_package_test.cmake.in b/contrib/minizip/test/find_package_test.cmake.in
index 6803ed4c1..55272ba72 100644
--- a/contrib/minizip/test/find_package_test.cmake.in
+++ b/contrib/minizip/test/find_package_test.cmake.in
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.12 ... 3.31)
+cmake_minimum_required(VERSION 3.12...3.31)
 
 project(
     minizip_find_package
diff --git a/test/add_subdirectory_exclude_test.cmake.in b/test/add_subdirectory_exclude_test.cmake.in
index 7b0934e3b..9077ce595 100644
--- a/test/add_subdirectory_exclude_test.cmake.in
+++ b/test/add_subdirectory_exclude_test.cmake.in
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.12 ... 3.31)
+cmake_minimum_required(VERSION 3.12...3.31)
 
 project(
     zlib_find_package_test
diff --git a/test/add_subdirectory_test.cmake.in b/test/add_subdirectory_test.cmake.in
index 0d3db212c..4201af82f 100644
--- a/test/add_subdirectory_test.cmake.in
+++ b/test/add_subdirectory_test.cmake.in
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.12 ... 3.31)
+cmake_minimum_required(VERSION 3.12...3.31)
 
 project(
     zlib_find_package_test
diff --git a/test/find_package_test.cmake.in b/test/find_package_test.cmake.in
index fbe0078a5..0f77d4977 100644
--- a/test/find_package_test.cmake.in
+++ b/test/find_package_test.cmake.in
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.12 ... 3.31)
+cmake_minimum_required(VERSION 3.12...3.31)
 
 project(
     zlib_find_package_test

From 953b3d79bf280dd3c83a2f6ef056bdfc8beb25e6 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 22 Jan 2025 21:54:53 +0100
Subject: [PATCH 115/128] CMake: Correct workflow line continuation.

---
 .github/workflows/msys-cygwin.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/msys-cygwin.yml b/.github/workflows/msys-cygwin.yml
index ef2593f2e..e76be9f0d 100644
--- a/.github/workflows/msys-cygwin.yml
+++ b/.github/workflows/msys-cygwin.yml
@@ -69,7 +69,7 @@ jobs:
           -B build \
           -DCMAKE_BUILD_TYPE=Release \
           -DZLIB_BUILD_MINIZIP=ON \
-          -DMINIZIP_ENABLE_BZIP2=OFF
+          -DMINIZIP_ENABLE_BZIP2=OFF \
           -G Ninja
     - name: Build
       run: cmake --build build --config Release -v -j1

From de4dea800767466543bc7e7afeb162414e36dad3 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Wed, 22 Jan 2025 23:37:38 +0100
Subject: [PATCH 116/128] CMake: Disable minizip on Cygwin.

---
 .github/workflows/msys-cygwin.yml | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/.github/workflows/msys-cygwin.yml b/.github/workflows/msys-cygwin.yml
index e76be9f0d..460954b03 100644
--- a/.github/workflows/msys-cygwin.yml
+++ b/.github/workflows/msys-cygwin.yml
@@ -68,8 +68,7 @@ jobs:
         cmake /cygdrive/d/a/zlib/zlib \
           -B build \
           -DCMAKE_BUILD_TYPE=Release \
-          -DZLIB_BUILD_MINIZIP=ON \
-          -DMINIZIP_ENABLE_BZIP2=OFF \
+          -DZLIB_BUILD_MINIZIP=OFF \
           -G Ninja
     - name: Build
       run: cmake --build build --config Release -v -j1

From 4891d8185a48f694c80a7c648b97ea48b3ad9165 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Fri, 24 Jan 2025 10:42:58 +0100
Subject: [PATCH 117/128] CMake: Give minizip a suffix on Cygwin as well.

---
 .github/workflows/msys-cygwin.yml | 3 ++-
 contrib/minizip/CMakeLists.txt    | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/msys-cygwin.yml b/.github/workflows/msys-cygwin.yml
index 460954b03..e76be9f0d 100644
--- a/.github/workflows/msys-cygwin.yml
+++ b/.github/workflows/msys-cygwin.yml
@@ -68,7 +68,8 @@ jobs:
         cmake /cygdrive/d/a/zlib/zlib \
           -B build \
           -DCMAKE_BUILD_TYPE=Release \
-          -DZLIB_BUILD_MINIZIP=OFF \
+          -DZLIB_BUILD_MINIZIP=ON \
+          -DMINIZIP_ENABLE_BZIP2=OFF \
           -G Ninja
     - name: Build
       run: cmake --build build --config Release -v -j1
diff --git a/contrib/minizip/CMakeLists.txt b/contrib/minizip/CMakeLists.txt
index 1109585cb..46d4348a5 100644
--- a/contrib/minizip/CMakeLists.txt
+++ b/contrib/minizip/CMakeLists.txt
@@ -114,10 +114,10 @@ set(MINIUNZIP_HDRS
     unzip.h
     zip.h)
 
-if(WIN32)
+if(WIN32 OR CYGWIN)
     set(minizip_static_suffix "s")
     set(CMAKE_DEBUG_POSTFIX "d")
-endif(WIN32)
+endif(WIN32 OR CYGWIN)
 
 if(MINIZIP_BUILD_SHARED)
     set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)

From 61a56bcbb0561e5c9a9a93af51d43e6a495b468f Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Fri, 24 Jan 2025 11:42:37 +0100
Subject: [PATCH 118/128] CMake: Make USE_FILE32API part of the interface.

---
 contrib/minizip/CMakeLists.txt | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/contrib/minizip/CMakeLists.txt b/contrib/minizip/CMakeLists.txt
index 46d4348a5..1aaf4ac74 100644
--- a/contrib/minizip/CMakeLists.txt
+++ b/contrib/minizip/CMakeLists.txt
@@ -131,9 +131,9 @@ if(MINIZIP_BUILD_SHARED)
         PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
                 $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
                 $<$<BOOL:${HAVE_UNISTD_H}>:HAVE_UNISTD_H=1>
-                $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>
         PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>
-                $<$<BOOL:${BZIP2_FOUND}>:HAVE_BZIP2=1>)
+                $<$<BOOL:${BZIP2_FOUND}>:HAVE_BZIP2=1>
+                $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>)
 
     if(NOT CYGWIN)
         set_target_properties(libminizip PROPERTIES SOVERSION
@@ -154,14 +154,12 @@ if(MINIZIP_BUILD_SHARED)
     add_executable(minizip ${MINIZIP_SRCS} ${MINIZIP_HDRS})
     set_target_properties(minizip PROPERTIES EXPORT_NAME minizip_executable)
     target_compile_definitions(
-        minizip PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
-                        $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>)
+        minizip PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>)
     target_link_libraries(minizip PRIVATE MINIZIP::minizip)
     add_executable(miniunzip ${MINIUNZIP_SRCS} ${MINIUNZIP_HDRS})
     set_target_properties(miniunzip PROPERTIES EXPORT_NAME miniunzip_executable)
     target_compile_definitions(
-        miniunzip PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
-                          $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>)
+        miniunzip PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>)
     target_link_libraries(miniunzip PRIVATE MINIZIP::minizip)
 endif(MINIZIP_BUILD_SHARED)
 
@@ -177,9 +175,9 @@ if(MINIZIP_BUILD_STATIC)
         PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
                 $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
                 $<$<BOOL:${HAVE_UNISTD_H}>:HAVE_UNISTD_H=1>
-                $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>
         PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>
-                $<$<BOOL:${BZIP2_FOUND}>:HAVE_BZIP2=1>)
+                $<$<BOOL:${BZIP2_FOUND}>:HAVE_BZIP2=1>
+                $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>)
     set_target_properties(
         libminizipstatic PROPERTIES EXPORT_NAME minizipstatic
                                     OUTPUT_NAME minizip${minizip_static_suffix})
@@ -195,15 +193,13 @@ if(MINIZIP_BUILD_STATIC)
     set_target_properties(minizipstatic PROPERTIES EXPORT_NAME
                                                    minizip_static_executable)
     target_compile_definitions(
-        minizipstatic PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
-                              $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>)
+        minizipstatic PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>)
     target_link_libraries(minizipstatic PRIVATE MINIZIP::minizipstatic)
     add_executable(miniunzipstatic ${MINIUNZIP_SRCS} ${MINIUNZIP_HDRS})
     set_target_properties(miniunzipstatic
                           PROPERTIES EXPORT_NAME miniunzip_static_executable)
     target_compile_definitions(
-        miniunzipstatic PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
-                                $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>)
+        miniunzipstatic PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>)
     target_link_libraries(miniunzipstatic PRIVATE MINIZIP::minizipstatic)
 endif(MINIZIP_BUILD_STATIC)
 

From ec346f1c39aa5569ec899d65ee5bba67a09ae2fc Mon Sep 17 00:00:00 2001
From: Mark Adler <madler@alumni.caltech.edu>
Date: Fri, 31 Jan 2025 20:11:37 -0800
Subject: [PATCH 119/128] Update Makefile to not recreate zconf.h and
 zconf.h.cmakein.

Both were removed as zconf.h.cmakein is no longer needed, and
zconf.h is made from zconf.h.in.
---
 .gitignore  |  1 +
 Makefile.in | 22 +++++++++++-----------
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/.gitignore b/.gitignore
index a06fb1095..cd4945c15 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,6 +13,7 @@
 *.gcno
 *.gcov
 
+zconf.h
 /example
 /example64
 /examplesh
diff --git a/Makefile.in b/Makefile.in
index 5da4ace7a..e86777f2f 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -355,15 +355,15 @@ docs: zlib.3.pdf
 zlib.3.pdf: $(SRCDIR)zlib.3
 	groff -mandoc -f H -T ps $(SRCDIR)zlib.3 | ps2pdf - $@
 
-zconf.h.cmakein: $(SRCDIR)zconf.h.in
-	-@ TEMPFILE=zconfh_$$; \
-	echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" >> $$TEMPFILE &&\
-	sed -f $$TEMPFILE $(SRCDIR)zconf.h.in > $@ &&\
-	touch -r $(SRCDIR)zconf.h.in $@ &&\
-	rm $$TEMPFILE
-
-zconf: $(SRCDIR)zconf.h.in
-	cp -p $(SRCDIR)zconf.h.in zconf.h
+# zconf.h.cmakein: $(SRCDIR)zconf.h.in
+# 	-@ TEMPFILE=zconfh_$$; \
+# 	echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" >> $$TEMPFILE &&\
+# 	sed -f $$TEMPFILE $(SRCDIR)zconf.h.in > $@ &&\
+# 	touch -r $(SRCDIR)zconf.h.in $@ &&\
+# 	rm $$TEMPFILE
+# 
+# zconf: $(SRCDIR)zconf.h.in
+# 	cp -p $(SRCDIR)zconf.h.in zconf.h
 
 minizip-test: static
 	cd contrib/minizip && { CC="$(CC)" CFLAGS="$(CFLAGS)" $(MAKE) test ; cd ../.. ; }
@@ -384,8 +384,8 @@ clean: minizip-clean
 	rm -f contrib/infback9/*.gcda contrib/infback9/*.gcno contrib/infback9/*.gcov
 
 maintainer-clean: distclean
-distclean: clean zconf zconf.h.cmakein
-	rm -f Makefile zlib.pc configure.log
+distclean: clean # zconf zconf.h.cmakein
+	rm -f Makefile zlib.pc configure.log zconf.h
 	-@rm -f .DS_Store
 	@if [ -f Makefile.in ]; then \
 	printf 'all:\n\t-@echo "Please use ./configure first.  Thank you."\n' > Makefile ; \

From ab0266a36271746cea957f9edefc2ccf78aa2074 Mon Sep 17 00:00:00 2001
From: Mark Adler <madler@alumni.caltech.edu>
Date: Sat, 1 Feb 2025 17:09:32 -0800
Subject: [PATCH 120/128] Avoid use of memcpy() in inflate when areas can
 overlap.

---
 inflate.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/inflate.c b/inflate.c
index 4feac091e..76bb8b95b 100644
--- a/inflate.c
+++ b/inflate.c
@@ -884,12 +884,12 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
                 if (copy > have) copy = have;
                 if (copy > left) copy = left;
                 if (copy == 0) goto inf_leave;
-                zmemcpy(put, next, copy);
                 have -= copy;
-                next += copy;
                 left -= copy;
-                put += copy;
                 state->length -= copy;
+                do {
+                    *put++ = *next++;
+                } while (--copy);
                 break;
             }
             Tracev((stderr, "inflate:       stored end\n"));

From ed1610791c0c681ee562bb3997e0f29bfae11b2d Mon Sep 17 00:00:00 2001
From: Mark Adler <madler@alumni.caltech.edu>
Date: Sun, 2 Feb 2025 11:04:40 -0800
Subject: [PATCH 121/128] Revert previous commit, restoring the memcpy() call.

The reported issue was due to an error in their test code, not in
inflate. This use of memcpy() in inflate is correct.
---
 inflate.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/inflate.c b/inflate.c
index 76bb8b95b..4feac091e 100644
--- a/inflate.c
+++ b/inflate.c
@@ -884,12 +884,12 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
                 if (copy > have) copy = have;
                 if (copy > left) copy = left;
                 if (copy == 0) goto inf_leave;
+                zmemcpy(put, next, copy);
                 have -= copy;
+                next += copy;
                 left -= copy;
+                put += copy;
                 state->length -= copy;
-                do {
-                    *put++ = *next++;
-                } while (--copy);
                 break;
             }
             Tracev((stderr, "inflate:       stored end\n"));

From c715ad71fe514b5e7768b1b334fc0b09f35842a3 Mon Sep 17 00:00:00 2001
From: Mark Adler <madler@alumni.caltech.edu>
Date: Wed, 5 Feb 2025 14:35:00 -0800
Subject: [PATCH 122/128] Restore zconf.h to distribution.

---
 .gitignore  |   3 +-
 Makefile.in |   9 +-
 zconf.h     | 544 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 551 insertions(+), 5 deletions(-)
 create mode 100644 zconf.h

diff --git a/.gitignore b/.gitignore
index cd4945c15..8d069ed38 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,7 +13,8 @@
 *.gcno
 *.gcov
 
-zconf.h
+/zconf.h
+/Makefile
 /example
 /example64
 /examplesh
diff --git a/Makefile.in b/Makefile.in
index e86777f2f..7010b25c5 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -362,8 +362,9 @@ zlib.3.pdf: $(SRCDIR)zlib.3
 # 	touch -r $(SRCDIR)zconf.h.in $@ &&\
 # 	rm $$TEMPFILE
 # 
-# zconf: $(SRCDIR)zconf.h.in
-# 	cp -p $(SRCDIR)zconf.h.in zconf.h
+
+zconf: $(SRCDIR)zconf.h.in
+	cp -p $(SRCDIR)zconf.h.in zconf.h
 
 minizip-test: static
 	cd contrib/minizip && { CC="$(CC)" CFLAGS="$(CFLAGS)" $(MAKE) test ; cd ../.. ; }
@@ -384,8 +385,8 @@ clean: minizip-clean
 	rm -f contrib/infback9/*.gcda contrib/infback9/*.gcno contrib/infback9/*.gcov
 
 maintainer-clean: distclean
-distclean: clean # zconf zconf.h.cmakein
-	rm -f Makefile zlib.pc configure.log zconf.h
+distclean: clean zconf # zconf.h.cmakein
+	rm -f Makefile zlib.pc configure.log
 	-@rm -f .DS_Store
 	@if [ -f Makefile.in ]; then \
 	printf 'all:\n\t-@echo "Please use ./configure first.  Thank you."\n' > Makefile ; \
diff --git a/zconf.h b/zconf.h
new file mode 100644
index 000000000..d6c159a1e
--- /dev/null
+++ b/zconf.h
@@ -0,0 +1,544 @@
+/* zconf.h -- configuration of the zlib compression library
+ * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* @(#) $Id$ */
+
+#ifndef ZCONF_H
+#define ZCONF_H
+
+/*
+ * If you *really* need a unique prefix for all types and library functions,
+ * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
+ * Even better than compiling with -DZ_PREFIX would be to use configure to set
+ * this permanently in zconf.h using "./configure --zprefix".
+ */
+#ifdef Z_PREFIX     /* may be set to #if 1 by ./configure */
+#  define Z_PREFIX_SET
+
+/* all linked symbols and init macros */
+#  define _dist_code            z__dist_code
+#  define _length_code          z__length_code
+#  define _tr_align             z__tr_align
+#  define _tr_flush_bits        z__tr_flush_bits
+#  define _tr_flush_block       z__tr_flush_block
+#  define _tr_init              z__tr_init
+#  define _tr_stored_block      z__tr_stored_block
+#  define _tr_tally             z__tr_tally
+#  define adler32               z_adler32
+#  define adler32_combine       z_adler32_combine
+#  define adler32_combine64     z_adler32_combine64
+#  define adler32_z             z_adler32_z
+#  ifndef Z_SOLO
+#    define compress              z_compress
+#    define compress2             z_compress2
+#    define compressBound         z_compressBound
+#  endif
+#  define crc32                 z_crc32
+#  define crc32_combine         z_crc32_combine
+#  define crc32_combine64       z_crc32_combine64
+#  define crc32_combine_gen     z_crc32_combine_gen
+#  define crc32_combine_gen64   z_crc32_combine_gen64
+#  define crc32_combine_op      z_crc32_combine_op
+#  define crc32_z               z_crc32_z
+#  define deflate               z_deflate
+#  define deflateBound          z_deflateBound
+#  define deflateCopy           z_deflateCopy
+#  define deflateEnd            z_deflateEnd
+#  define deflateGetDictionary  z_deflateGetDictionary
+#  define deflateInit           z_deflateInit
+#  define deflateInit2          z_deflateInit2
+#  define deflateInit2_         z_deflateInit2_
+#  define deflateInit_          z_deflateInit_
+#  define deflateParams         z_deflateParams
+#  define deflatePending        z_deflatePending
+#  define deflatePrime          z_deflatePrime
+#  define deflateReset          z_deflateReset
+#  define deflateResetKeep      z_deflateResetKeep
+#  define deflateSetDictionary  z_deflateSetDictionary
+#  define deflateSetHeader      z_deflateSetHeader
+#  define deflateTune           z_deflateTune
+#  define deflateUsed           z_deflateUsed
+#  define deflate_copyright     z_deflate_copyright
+#  define get_crc_table         z_get_crc_table
+#  ifndef Z_SOLO
+#    define gz_error              z_gz_error
+#    define gz_intmax             z_gz_intmax
+#    define gz_strwinerror        z_gz_strwinerror
+#    define gzbuffer              z_gzbuffer
+#    define gzclearerr            z_gzclearerr
+#    define gzclose               z_gzclose
+#    define gzclose_r             z_gzclose_r
+#    define gzclose_w             z_gzclose_w
+#    define gzdirect              z_gzdirect
+#    define gzdopen               z_gzdopen
+#    define gzeof                 z_gzeof
+#    define gzerror               z_gzerror
+#    define gzflush               z_gzflush
+#    define gzfread               z_gzfread
+#    define gzfwrite              z_gzfwrite
+#    define gzgetc                z_gzgetc
+#    define gzgetc_               z_gzgetc_
+#    define gzgets                z_gzgets
+#    define gzoffset              z_gzoffset
+#    define gzoffset64            z_gzoffset64
+#    define gzopen                z_gzopen
+#    define gzopen64              z_gzopen64
+#    ifdef _WIN32
+#      define gzopen_w              z_gzopen_w
+#    endif
+#    define gzprintf              z_gzprintf
+#    define gzputc                z_gzputc
+#    define gzputs                z_gzputs
+#    define gzread                z_gzread
+#    define gzrewind              z_gzrewind
+#    define gzseek                z_gzseek
+#    define gzseek64              z_gzseek64
+#    define gzsetparams           z_gzsetparams
+#    define gztell                z_gztell
+#    define gztell64              z_gztell64
+#    define gzungetc              z_gzungetc
+#    define gzvprintf             z_gzvprintf
+#    define gzwrite               z_gzwrite
+#  endif
+#  define inflate               z_inflate
+#  define inflateBack           z_inflateBack
+#  define inflateBackEnd        z_inflateBackEnd
+#  define inflateBackInit       z_inflateBackInit
+#  define inflateBackInit_      z_inflateBackInit_
+#  define inflateCodesUsed      z_inflateCodesUsed
+#  define inflateCopy           z_inflateCopy
+#  define inflateEnd            z_inflateEnd
+#  define inflateGetDictionary  z_inflateGetDictionary
+#  define inflateGetHeader      z_inflateGetHeader
+#  define inflateInit           z_inflateInit
+#  define inflateInit2          z_inflateInit2
+#  define inflateInit2_         z_inflateInit2_
+#  define inflateInit_          z_inflateInit_
+#  define inflateMark           z_inflateMark
+#  define inflatePrime          z_inflatePrime
+#  define inflateReset          z_inflateReset
+#  define inflateReset2         z_inflateReset2
+#  define inflateResetKeep      z_inflateResetKeep
+#  define inflateSetDictionary  z_inflateSetDictionary
+#  define inflateSync           z_inflateSync
+#  define inflateSyncPoint      z_inflateSyncPoint
+#  define inflateUndermine      z_inflateUndermine
+#  define inflateValidate       z_inflateValidate
+#  define inflate_copyright     z_inflate_copyright
+#  define inflate_fast          z_inflate_fast
+#  define inflate_table         z_inflate_table
+#  ifndef Z_SOLO
+#    define uncompress            z_uncompress
+#    define uncompress2           z_uncompress2
+#  endif
+#  define zError                z_zError
+#  ifndef Z_SOLO
+#    define zcalloc               z_zcalloc
+#    define zcfree                z_zcfree
+#  endif
+#  define zlibCompileFlags      z_zlibCompileFlags
+#  define zlibVersion           z_zlibVersion
+
+/* all zlib typedefs in zlib.h and zconf.h */
+#  define Byte                  z_Byte
+#  define Bytef                 z_Bytef
+#  define alloc_func            z_alloc_func
+#  define charf                 z_charf
+#  define free_func             z_free_func
+#  ifndef Z_SOLO
+#    define gzFile                z_gzFile
+#  endif
+#  define gz_header             z_gz_header
+#  define gz_headerp            z_gz_headerp
+#  define in_func               z_in_func
+#  define intf                  z_intf
+#  define out_func              z_out_func
+#  define uInt                  z_uInt
+#  define uIntf                 z_uIntf
+#  define uLong                 z_uLong
+#  define uLongf                z_uLongf
+#  define voidp                 z_voidp
+#  define voidpc                z_voidpc
+#  define voidpf                z_voidpf
+
+/* all zlib structs in zlib.h and zconf.h */
+#  define gz_header_s           z_gz_header_s
+#  define internal_state        z_internal_state
+
+#endif
+
+#if defined(__MSDOS__) && !defined(MSDOS)
+#  define MSDOS
+#endif
+#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
+#  define OS2
+#endif
+#if defined(_WINDOWS) && !defined(WINDOWS)
+#  define WINDOWS
+#endif
+#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
+#  ifndef WIN32
+#    define WIN32
+#  endif
+#endif
+#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
+#  if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
+#    ifndef SYS16BIT
+#      define SYS16BIT
+#    endif
+#  endif
+#endif
+
+/*
+ * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
+ * than 64k bytes at a time (needed on systems with 16-bit int).
+ */
+#ifdef SYS16BIT
+#  define MAXSEG_64K
+#endif
+#ifdef MSDOS
+#  define UNALIGNED_OK
+#endif
+
+#ifdef __STDC_VERSION__
+#  ifndef STDC
+#    define STDC
+#  endif
+#  if __STDC_VERSION__ >= 199901L
+#    ifndef STDC99
+#      define STDC99
+#    endif
+#  endif
+#endif
+#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
+#  define STDC
+#endif
+#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
+#  define STDC
+#endif
+#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
+#  define STDC
+#endif
+#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
+#  define STDC
+#endif
+
+#if defined(__OS400__) && !defined(STDC)    /* iSeries (formerly AS/400). */
+#  define STDC
+#endif
+
+#ifndef STDC
+#  ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
+#    define const       /* note: need a more gentle solution here */
+#  endif
+#endif
+
+#ifndef z_const
+#  ifdef ZLIB_CONST
+#    define z_const const
+#  else
+#    define z_const
+#  endif
+#endif
+
+#ifdef Z_SOLO
+#  ifdef _WIN64
+     typedef unsigned long long z_size_t;
+#  else
+     typedef unsigned long z_size_t;
+#  endif
+#else
+#  define z_longlong long long
+#  if defined(NO_SIZE_T)
+     typedef unsigned NO_SIZE_T z_size_t;
+#  elif defined(STDC)
+#    include <stddef.h>
+     typedef size_t z_size_t;
+#  else
+     typedef unsigned long z_size_t;
+#  endif
+#  undef z_longlong
+#endif
+
+/* Maximum value for memLevel in deflateInit2 */
+#ifndef MAX_MEM_LEVEL
+#  ifdef MAXSEG_64K
+#    define MAX_MEM_LEVEL 8
+#  else
+#    define MAX_MEM_LEVEL 9
+#  endif
+#endif
+
+/* Maximum value for windowBits in deflateInit2 and inflateInit2.
+ * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
+ * created by gzip. (Files created by minigzip can still be extracted by
+ * gzip.)
+ */
+#ifndef MAX_WBITS
+#  define MAX_WBITS   15 /* 32K LZ77 window */
+#endif
+
+/* The memory requirements for deflate are (in bytes):
+            (1 << (windowBits+2)) +  (1 << (memLevel+9))
+ that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)
+ plus a few kilobytes for small objects. For example, if you want to reduce
+ the default memory requirements from 256K to 128K, compile with
+     make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
+ Of course this will generally degrade compression (there's no free lunch).
+
+   The memory requirements for inflate are (in bytes) 1 << windowBits
+ that is, 32K for windowBits=15 (default value) plus about 7 kilobytes
+ for small objects.
+*/
+
+                        /* Type declarations */
+
+#ifndef OF /* function prototypes */
+#  ifdef STDC
+#    define OF(args)  args
+#  else
+#    define OF(args)  ()
+#  endif
+#endif
+
+/* The following definitions for FAR are needed only for MSDOS mixed
+ * model programming (small or medium model with some far allocations).
+ * This was tested only with MSC; for other MSDOS compilers you may have
+ * to define NO_MEMCPY in zutil.h.  If you don't need the mixed model,
+ * just define FAR to be empty.
+ */
+#ifdef SYS16BIT
+#  if defined(M_I86SM) || defined(M_I86MM)
+     /* MSC small or medium model */
+#    define SMALL_MEDIUM
+#    ifdef _MSC_VER
+#      define FAR _far
+#    else
+#      define FAR far
+#    endif
+#  endif
+#  if (defined(__SMALL__) || defined(__MEDIUM__))
+     /* Turbo C small or medium model */
+#    define SMALL_MEDIUM
+#    ifdef __BORLANDC__
+#      define FAR _far
+#    else
+#      define FAR far
+#    endif
+#  endif
+#endif
+
+#if defined(WINDOWS) || defined(WIN32)
+   /* If building or using zlib as a DLL, define ZLIB_DLL.
+    * This is not mandatory, but it offers a little performance increase.
+    */
+#  ifdef ZLIB_DLL
+#    if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
+#      ifdef ZLIB_INTERNAL
+#        define ZEXTERN extern __declspec(dllexport)
+#      else
+#        define ZEXTERN extern __declspec(dllimport)
+#      endif
+#    endif
+#  endif  /* ZLIB_DLL */
+   /* If building or using zlib with the WINAPI/WINAPIV calling convention,
+    * define ZLIB_WINAPI.
+    * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
+    */
+#  ifdef ZLIB_WINAPI
+#    ifdef FAR
+#      undef FAR
+#    endif
+#    ifndef WIN32_LEAN_AND_MEAN
+#      define WIN32_LEAN_AND_MEAN
+#    endif
+#    include <windows.h>
+     /* No need for _export, use ZLIB.DEF instead. */
+     /* For complete Windows compatibility, use WINAPI, not __stdcall. */
+#    define ZEXPORT WINAPI
+#    ifdef WIN32
+#      define ZEXPORTVA WINAPIV
+#    else
+#      define ZEXPORTVA FAR CDECL
+#    endif
+#  endif
+#endif
+
+#if defined (__BEOS__)
+#  ifdef ZLIB_DLL
+#    ifdef ZLIB_INTERNAL
+#      define ZEXPORT   __declspec(dllexport)
+#      define ZEXPORTVA __declspec(dllexport)
+#    else
+#      define ZEXPORT   __declspec(dllimport)
+#      define ZEXPORTVA __declspec(dllimport)
+#    endif
+#  endif
+#endif
+
+#ifndef ZEXTERN
+#  define ZEXTERN extern
+#endif
+#ifndef ZEXPORT
+#  define ZEXPORT
+#endif
+#ifndef ZEXPORTVA
+#  define ZEXPORTVA
+#endif
+
+#ifndef FAR
+#  define FAR
+#endif
+
+#if !defined(__MACTYPES__)
+typedef unsigned char  Byte;  /* 8 bits */
+#endif
+typedef unsigned int   uInt;  /* 16 bits or more */
+typedef unsigned long  uLong; /* 32 bits or more */
+
+#ifdef SMALL_MEDIUM
+   /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
+#  define Bytef Byte FAR
+#else
+   typedef Byte  FAR Bytef;
+#endif
+typedef char  FAR charf;
+typedef int   FAR intf;
+typedef uInt  FAR uIntf;
+typedef uLong FAR uLongf;
+
+#ifdef STDC
+   typedef void const *voidpc;
+   typedef void FAR   *voidpf;
+   typedef void       *voidp;
+#else
+   typedef Byte const *voidpc;
+   typedef Byte FAR   *voidpf;
+   typedef Byte       *voidp;
+#endif
+
+#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
+#  include <limits.h>
+#  if (UINT_MAX == 0xffffffffUL)
+#    define Z_U4 unsigned
+#  elif (ULONG_MAX == 0xffffffffUL)
+#    define Z_U4 unsigned long
+#  elif (USHRT_MAX == 0xffffffffUL)
+#    define Z_U4 unsigned short
+#  endif
+#endif
+
+#ifdef Z_U4
+   typedef Z_U4 z_crc_t;
+#else
+   typedef unsigned long z_crc_t;
+#endif
+
+#ifdef HAVE_UNISTD_H    /* may be set to #if 1 by ./configure */
+#  define Z_HAVE_UNISTD_H
+#endif
+
+#ifdef HAVE_STDARG_H    /* may be set to #if 1 by ./configure */
+#  define Z_HAVE_STDARG_H
+#endif
+
+#ifdef STDC
+#  ifndef Z_SOLO
+#    include <sys/types.h>      /* for off_t */
+#  endif
+#endif
+
+#if defined(STDC) || defined(Z_HAVE_STDARG_H)
+#  ifndef Z_SOLO
+#    include <stdarg.h>         /* for va_list */
+#  endif
+#endif
+
+#ifdef _WIN32
+#  ifndef Z_SOLO
+#    include <stddef.h>         /* for wchar_t */
+#  endif
+#endif
+
+/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
+ * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
+ * though the former does not conform to the LFS document), but considering
+ * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
+ * equivalently requesting no 64-bit operations
+ */
+#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
+#  undef _LARGEFILE64_SOURCE
+#endif
+
+#ifndef Z_HAVE_UNISTD_H
+#  if defined(__WATCOMC__) || defined(__GO32__) || \
+      (defined(_LARGEFILE64_SOURCE) && !defined(_WIN32))
+#    define Z_HAVE_UNISTD_H
+#  endif
+#endif
+#ifndef Z_SOLO
+#  if defined(Z_HAVE_UNISTD_H)
+#    include <unistd.h>         /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
+#    ifdef VMS
+#      include <unixio.h>       /* for off_t */
+#    endif
+#    ifndef z_off_t
+#      define z_off_t off_t
+#    endif
+#  endif
+#endif
+
+#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
+#  define Z_LFS64
+#endif
+
+#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
+#  define Z_LARGE64
+#endif
+
+#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
+#  define Z_WANT64
+#endif
+
+#if !defined(SEEK_SET) && !defined(Z_SOLO)
+#  define SEEK_SET        0       /* Seek from beginning of file.  */
+#  define SEEK_CUR        1       /* Seek from current position.  */
+#  define SEEK_END        2       /* Set file pointer to EOF plus "offset" */
+#endif
+
+#ifndef z_off_t
+#  define z_off_t long long
+#endif
+
+#if !defined(_WIN32) && defined(Z_LARGE64)
+#  define z_off64_t off64_t
+#elif defined(__MINGW32__)
+#  define z_off64_t long long
+#elif defined(_WIN32) && !defined(__GNUC__)
+#  define z_off64_t __int64
+#elif defined(__GO32__)
+#  define z_off64_t offset_t
+#else
+#  define z_off64_t z_off_t
+#endif
+
+/* MVS linker does not support external names larger than 8 bytes */
+#if defined(__MVS__)
+  #pragma map(deflateInit_,"DEIN")
+  #pragma map(deflateInit2_,"DEIN2")
+  #pragma map(deflateEnd,"DEEND")
+  #pragma map(deflateBound,"DEBND")
+  #pragma map(inflateInit_,"ININ")
+  #pragma map(inflateInit2_,"ININ2")
+  #pragma map(inflateEnd,"INEND")
+  #pragma map(inflateSync,"INSY")
+  #pragma map(inflateSetDictionary,"INSEDI")
+  #pragma map(compressBound,"CMBND")
+  #pragma map(inflate_table,"INTABL")
+  #pragma map(inflate_fast,"INFA")
+  #pragma map(inflate_copyright,"INCOPY")
+#endif
+
+#endif /* ZCONF_H */

From 0b29118367551a44612a725970f7f6ff258cab06 Mon Sep 17 00:00:00 2001
From: spectralio <63775040+spectralio@users.noreply.github.com>
Date: Wed, 5 Feb 2025 13:01:28 +0100
Subject: [PATCH 123/128] Fix Ada bindings on x64.

---
 contrib/ada/zlib-thin.adb | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/contrib/ada/zlib-thin.adb b/contrib/ada/zlib-thin.adb
index 0ca4a7120..b28f922af 100644
--- a/contrib/ada/zlib-thin.adb
+++ b/contrib/ada/zlib-thin.adb
@@ -12,7 +12,8 @@ package body ZLib.Thin is
 
    ZLIB_VERSION  : constant Chars_Ptr := zlibVersion;
 
-   Z_Stream_Size : constant Int := Z_Stream'Size / System.Storage_Unit;
+   Dummy : Z_Stream;
+   Z_Stream_Size : constant Int := Dummy'Size / System.Storage_Unit;
 
    --------------
    -- Avail_In --

From d20659fc74975e27962655d1b337da8cf3646638 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Thu, 6 Feb 2025 08:28:18 +0100
Subject: [PATCH 124/128] Repair MinGW cmake build.

---
 CMakeLists.txt     | 5 -----
 win32/Makefile.gcc | 2 +-
 win32/zlib1.rc     | 5 +----
 3 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d963e7c04..a46b2c623 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -155,11 +155,6 @@ set(ZLIB_SRCS
     uncompr.c
     zutil.c)
 
-set_source_files_properties(
-    win32/zlib1.rc
-    PROPERTIES COMPILE_FLAGS
-               $<$<STREQUAL:${CMAKE_RC_OUTPUT_EXTENSION},.obj>:-DGCC_WINDRES>)
-
 if(WIN32)
     set(zlib_static_suffix "s")
     set(CMAKE_DEBUG_POSTFIX "d")
diff --git a/win32/Makefile.gcc b/win32/Makefile.gcc
index 081e391eb..35172fb35 100644
--- a/win32/Makefile.gcc
+++ b/win32/Makefile.gcc
@@ -50,7 +50,7 @@ AR = $(PREFIX)ar
 ARFLAGS = rcs
 
 RC = $(PREFIX)windres
-RCFLAGS = --define GCC_WINDRES
+RCFLAGS =
 
 STRIP = $(PREFIX)strip
 
diff --git a/win32/zlib1.rc b/win32/zlib1.rc
index ceb4ee5c6..e4847d85b 100644
--- a/win32/zlib1.rc
+++ b/win32/zlib1.rc
@@ -1,11 +1,8 @@
 #include <winver.h>
 #include "../zlib.h"
 
-#ifdef GCC_WINDRES
 VS_VERSION_INFO		VERSIONINFO
-#else
-VS_VERSION_INFO		VERSIONINFO	MOVEABLE IMPURE LOADONCALL DISCARDABLE
-#endif
+
   FILEVERSION		ZLIB_VER_MAJOR,ZLIB_VER_MINOR,ZLIB_VER_REVISION,0
   PRODUCTVERSION	ZLIB_VER_MAJOR,ZLIB_VER_MINOR,ZLIB_VER_REVISION,0
   FILEFLAGSMASK		VS_FFI_FILEFLAGSMASK

From 8a844d434f0eef87d972ae6406b00968f7c52944 Mon Sep 17 00:00:00 2001
From: Mark Adler <madler@alumni.caltech.edu>
Date: Thu, 6 Feb 2025 17:10:43 -0800
Subject: [PATCH 125/128] Use zconf.h instead of zconf.h.in for cmake.

---
 CMakeLists.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a46b2c623..83f0ffd61 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,12 +52,12 @@ set(CPACK_INCLUDED TRUE)
 if(NOT ZLIB_CONF_WRITTEN)
     set(Z_PREFIX ${ZLIB_PREFIX})
     set(CONF_OUT_FILE ${zlib_BINARY_DIR}/zconf.h.cmakein)
-    file(READ ${zlib_SOURCE_DIR}/zconf.h.in ZCONF_CONTENT LIMIT 245)
+    file(READ ${zlib_SOURCE_DIR}/zconf.h ZCONF_CONTENT LIMIT 245)
     file(WRITE ${CONF_OUT_FILE} ${ZCONF_CONTENT})
     file(APPEND ${CONF_OUT_FILE} "#cmakedefine Z_PREFIX 1\n")
     file(APPEND ${CONF_OUT_FILE} "#cmakedefine HAVE_STDARG_H 1\n")
     file(APPEND ${CONF_OUT_FILE} "#cmakedefine HAVE_UNISTD_H 1\n")
-    file(READ ${zlib_SOURCE_DIR}/zconf.h.in ZCONF_CONTENT OFFSET 244)
+    file(READ ${zlib_SOURCE_DIR}/zconf.h ZCONF_CONTENT OFFSET 244)
     set(FIRST_ITEM TRUE)
 
     foreach(item IN LISTS ZCONF_CONTENT)

From 00161eff1de25e9eed56bffdbe58f2c07ca16e51 Mon Sep 17 00:00:00 2001
From: Vollstrecker <github@vollstreckernet.de>
Date: Wed, 12 Feb 2025 22:46:34 +0100
Subject: [PATCH 126/128] Do not look for zconf.h in the source directory.

Temporary patch for cmake, but too violent. A better solution will
need to be found.
---
 zlib.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/zlib.h b/zlib.h
index ad33815f1..8cafa325a 100644
--- a/zlib.h
+++ b/zlib.h
@@ -31,7 +31,7 @@
 #ifndef ZLIB_H
 #define ZLIB_H
 
-#include "zconf.h"
+#include <zconf.h>
 
 #ifdef __cplusplus
 extern "C" {

From 7108497fda9d4536a1afade7f42266e06dca4488 Mon Sep 17 00:00:00 2001
From: Mark Adler <madler@alumni.caltech.edu>
Date: Thu, 13 Feb 2025 22:44:48 -0800
Subject: [PATCH 127/128] Check that HAVE_UNISTD_H and HAVE_STDARG_H are not
 defined as 0.

---
 configure  | 4 ++--
 zconf.h    | 4 ++--
 zconf.h.in | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/configure b/configure
index 393c23c94..1834659fd 100755
--- a/configure
+++ b/configure
@@ -611,7 +611,7 @@ cat > $test.c <<EOF
 int main() { return 0; }
 EOF
 if try $CC -c $CFLAGS $test.c; then
-  sed < zconf.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
+  sed < zconf.h "/^#if HAVE_UNISTD_H-0.* may be/s/ HAVE_UNISTD_H-0\(.*\) may be/ 1\1 was/" > zconf.temp.h
   mv zconf.temp.h zconf.h
   echo "Checking for unistd.h... Yes." | tee -a configure.log
 else
@@ -626,7 +626,7 @@ cat > $test.c <<EOF
 int main() { return 0; }
 EOF
 if try $CC -c $CFLAGS $test.c; then
-  sed < zconf.h "/^#ifdef HAVE_STDARG_H.* may be/s/def HAVE_STDARG_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
+  sed < zconf.h "/^#if HAVE_STDARG_H-0.* may be/s/ HAVE_STDARG_H-0\(.*\) may be/ 1\1 was/" > zconf.temp.h
   mv zconf.temp.h zconf.h
   echo "Checking for stdarg.h... Yes." | tee -a configure.log
 else
diff --git a/zconf.h b/zconf.h
index d6c159a1e..bc3ef079b 100644
--- a/zconf.h
+++ b/zconf.h
@@ -436,11 +436,11 @@ typedef uLong FAR uLongf;
    typedef unsigned long z_crc_t;
 #endif
 
-#ifdef HAVE_UNISTD_H    /* may be set to #if 1 by ./configure */
+#if HAVE_UNISTD_H-0     /* may be set to #if 1 by ./configure */
 #  define Z_HAVE_UNISTD_H
 #endif
 
-#ifdef HAVE_STDARG_H    /* may be set to #if 1 by ./configure */
+#if HAVE_STDARG_H-0     /* may be set to #if 1 by ./configure */
 #  define Z_HAVE_STDARG_H
 #endif
 
diff --git a/zconf.h.in b/zconf.h.in
index d6c159a1e..bc3ef079b 100644
--- a/zconf.h.in
+++ b/zconf.h.in
@@ -436,11 +436,11 @@ typedef uLong FAR uLongf;
    typedef unsigned long z_crc_t;
 #endif
 
-#ifdef HAVE_UNISTD_H    /* may be set to #if 1 by ./configure */
+#if HAVE_UNISTD_H-0     /* may be set to #if 1 by ./configure */
 #  define Z_HAVE_UNISTD_H
 #endif
 
-#ifdef HAVE_STDARG_H    /* may be set to #if 1 by ./configure */
+#if HAVE_STDARG_H-0     /* may be set to #if 1 by ./configure */
 #  define Z_HAVE_STDARG_H
 #endif
 

From 5a82f71ed1dfc0bec044d9702463dbdf84ea3b71 Mon Sep 17 00:00:00 2001
From: Vollstrecker <werner@vollstreckernet.de>
Date: Tue, 18 Feb 2025 08:47:58 +0100
Subject: [PATCH 128/128] Use generated zconf.h in cmake build.

This restores the inclusion of the local zconf.h (double quoted)
in normal usage.
---
 CMakeLists.txt      | 7 ++++---
 test/CMakeLists.txt | 8 +++++---
 zlib.h              | 6 +++++-
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 83f0ffd61..aa7359121 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -119,7 +119,6 @@ unset(CMAKE_COMPILE_FLAGS)
 set(ZLIB_PC ${zlib_BINARY_DIR}/zlib.pc)
 configure_file(${zlib_SOURCE_DIR}/zlib.pc.cmakein ${ZLIB_PC} @ONLY)
 configure_file(${zlib_BINARY_DIR}/zconf.h.cmakein ${zlib_BINARY_DIR}/zconf.h)
-include_directories(${zlib_BINARY_DIR} ${zlib_SOURCE_DIR})
 
 # ============================================================================
 # zlib
@@ -172,7 +171,8 @@ if(ZLIB_BUILD_SHARED)
                $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
     target_compile_definitions(
         zlib
-        PRIVATE $<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
+        PRIVATE ZLIB_BUILD
+                $<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
                 $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
                 $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
                 $<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>
@@ -214,7 +214,8 @@ if(ZLIB_BUILD_STATIC)
                $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
     target_compile_definitions(
         zlibstatic
-        PRIVATE $<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
+        PRIVATE ZLIB_BUILD
+                $<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
                 $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
                 $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
                 $<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 46c07ebf6..0d2844d8c 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -16,6 +16,7 @@ endfunction()
 if(ZLIB_BUILD_SHARED)
     add_executable(zlib_example example.c)
     target_link_libraries(zlib_example ZLIB::ZLIB)
+    target_compile_definitions(zlib_example PRIVATE ZLIB_BUILD)
     add_test(NAME zlib_example COMMAND zlib_example)
 
     add_executable(minigzip minigzip.c)
@@ -38,7 +39,7 @@ if(ZLIB_BUILD_SHARED)
         add_executable(zlib_example64 example.c)
         target_compile_definitions(
             zlib_example64
-            PRIVATE LARGEFILE64_SOURCE=1
+            PRIVATE ZLIB_BUILD
                     $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
         target_link_libraries(zlib_example64 ZLIB::ZLIB)
         add_test(NAME zlib_example64 COMMAND zlib_example64)
@@ -61,7 +62,8 @@ if(ZLIB_BUILD_STATIC)
     target_link_libraries(zlib_static_example ZLIB::ZLIBSTATIC)
     target_compile_definitions(
         zlib_static_example
-        PRIVATE $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
+        PRIVATE ZLIB_BUILD
+                $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
     add_test(NAME zlib_static_example COMMAND zlib_static_example)
 
     add_executable(static_minigzip minigzip.c)
@@ -116,7 +118,7 @@ if(ZLIB_BUILD_STATIC)
         add_executable(zlib_static_example64 example.c)
         target_compile_definitions(
             zlib_static_example64
-            PRIVATE LARGEFILE64_SOURCE=1
+            PRIVATE ZLIB_BUILD
                     $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
         target_link_libraries(zlib_static_example64 ZLIB::ZLIBSTATIC)
         add_test(NAME zlib_static_example64 COMMAND zlib_static_example64)
diff --git a/zlib.h b/zlib.h
index 8cafa325a..c75090b0f 100644
--- a/zlib.h
+++ b/zlib.h
@@ -31,7 +31,11 @@
 #ifndef ZLIB_H
 #define ZLIB_H
 
-#include <zconf.h>
+#ifdef ZLIB_BUILD
+#  include <zconf.h>
+#else
+# include "zconf.h"
+#endif
 
 #ifdef __cplusplus
 extern "C" {
