diff options
| author | Vollstrecker <github@vollstreckernet.de> | 2026-02-15 00:15:41 +0100 |
|---|---|---|
| committer | Mark Adler <git@madler.net> | 2026-02-16 02:25:37 -0800 |
| commit | 0b3932c80dc338b36fe1b8bacd216bacb8991c17 (patch) | |
| tree | 0d0a2c2795ec4210d4e270d4e23f5007b07dd661 /contrib | |
| parent | 965fbb574f2d2117329ed7e48536cae1012ce672 (diff) | |
| download | zlib-0b3932c80dc338b36fe1b8bacd216bacb8991c17.tar.gz zlib-0b3932c80dc338b36fe1b8bacd216bacb8991c17.tar.bz2 zlib-0b3932c80dc338b36fe1b8bacd216bacb8991c17.zip | |
CMake: Add build for zlib1.dll with zlib and minizip.
zlib1.dll is the legacy zlib + minizip DLL.
Diffstat (limited to 'contrib')
| -rw-r--r-- | contrib/CMakeLists.txt | 6 | ||||
| -rw-r--r-- | contrib/minizip/unzip.c | 3 | ||||
| -rw-r--r-- | contrib/minizip/zip.c | 3 | ||||
| -rw-r--r-- | contrib/zlib1-dll/CMakeLists.txt | 196 | ||||
| -rw-r--r-- | contrib/zlib1-dll/readme.txt | 21 |
5 files changed, 229 insertions, 0 deletions
diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index c716d6a3..4c7bc688 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt | |||
| @@ -52,4 +52,10 @@ zlib_add_contrib_lib(PUFF "puff decompress library" puff) | |||
| 52 | 52 | ||
| 53 | if(WIN32) | 53 | if(WIN32) |
| 54 | zlib_add_contrib_lib(TESTZLIB "testzlib binary" testzlib) | 54 | zlib_add_contrib_lib(TESTZLIB "testzlib binary" testzlib) |
| 55 | |||
| 56 | if (ZLIB_BUILD_ZLIB1_DLL) | ||
| 57 | add_subdirectory(zlib1-dll/) | ||
| 58 | endif (ZLIB_BUILD_ZLIB1_DLL) | ||
| 59 | |||
| 60 | option(ZLIB_BUILD_ZLIB1_DLL "Build the legacy zlib + minizip DLL" OFF) | ||
| 55 | endif(WIN32) | 61 | endif(WIN32) |
diff --git a/contrib/minizip/unzip.c b/contrib/minizip/unzip.c index 8513aec6..44c51bd3 100644 --- a/contrib/minizip/unzip.c +++ b/contrib/minizip/unzip.c | |||
| @@ -68,6 +68,9 @@ | |||
| 68 | #include <stdlib.h> | 68 | #include <stdlib.h> |
| 69 | #include <string.h> | 69 | #include <string.h> |
| 70 | 70 | ||
| 71 | #ifdef ZLIB_DLL | ||
| 72 | # undef ZLIB_DLL | ||
| 73 | #endif | ||
| 71 | #include "zlib.h" | 74 | #include "zlib.h" |
| 72 | #include "unzip.h" | 75 | #include "unzip.h" |
| 73 | 76 | ||
diff --git a/contrib/minizip/zip.c b/contrib/minizip/zip.c index 4fc87d48..46943cec 100644 --- a/contrib/minizip/zip.c +++ b/contrib/minizip/zip.c | |||
| @@ -29,6 +29,9 @@ | |||
| 29 | #ifndef ZLIB_CONST | 29 | #ifndef ZLIB_CONST |
| 30 | # define ZLIB_CONST | 30 | # define ZLIB_CONST |
| 31 | #endif | 31 | #endif |
| 32 | #ifdef ZLIB_DLL | ||
| 33 | # undef ZLIB_DLL | ||
| 34 | #endif | ||
| 32 | #include "zlib.h" | 35 | #include "zlib.h" |
| 33 | #include "zip.h" | 36 | #include "zip.h" |
| 34 | 37 | ||
diff --git a/contrib/zlib1-dll/CMakeLists.txt b/contrib/zlib1-dll/CMakeLists.txt new file mode 100644 index 00000000..c9825aa0 --- /dev/null +++ b/contrib/zlib1-dll/CMakeLists.txt | |||
| @@ -0,0 +1,196 @@ | |||
| 1 | cmake_minimum_required(VERSION 3.12...3.31) | ||
| 2 | |||
| 3 | project( | ||
| 4 | zlib1-dll | ||
| 5 | LANGUAGES C | ||
| 6 | VERSION 1.3.1.2 | ||
| 7 | HOMEPAGE_URL "https://zlib.net/" | ||
| 8 | DESCRIPTION "zlib1.dll is the legacy DLL with zlib and minizip") | ||
| 9 | |||
| 10 | # ============================================================================ | ||
| 11 | # configuration | ||
| 12 | # ============================================================================ | ||
| 13 | |||
| 14 | if(NOT WIN32) | ||
| 15 | message(FATAL_ERROR "This creates zlib1.<DLL>, Nothing else") | ||
| 16 | endif(NOT WIN32) | ||
| 17 | |||
| 18 | option(ENABLE_BZIP2 "Build with bzip2 support" OFF) | ||
| 19 | set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) | ||
| 20 | |||
| 21 | include(CheckCSourceCompiles) | ||
| 22 | include(CheckFunctionExists) | ||
| 23 | include(CheckIncludeFile) | ||
| 24 | include(CMakePackageConfigHelpers) | ||
| 25 | include(CheckTypeSize) | ||
| 26 | include(CPack) | ||
| 27 | include(GNUInstallDirs) | ||
| 28 | |||
| 29 | if(NOT ZLIB_CONF_WRITTEN) | ||
| 30 | set(CONF_OUT_FILE ${zlib1-dll_BINARY_DIR}/zconf.h.cmakein) | ||
| 31 | file(READ ../../zconf.h ZCONF_CONTENT LIMIT 245) | ||
| 32 | file(WRITE ${CONF_OUT_FILE} ${ZCONF_CONTENT}) | ||
| 33 | file(APPEND ${CONF_OUT_FILE} "#cmakedefine Z_PREFIX 1\n") | ||
| 34 | file(APPEND ${CONF_OUT_FILE} "#cmakedefine HAVE_STDARG_H 1\n") | ||
| 35 | file(APPEND ${CONF_OUT_FILE} "#cmakedefine HAVE_UNISTD_H 1\n") | ||
| 36 | file(READ ../../zconf.h ZCONF_CONTENT OFFSET 244) | ||
| 37 | set(FIRST_ITEM TRUE) | ||
| 38 | |||
| 39 | foreach(item IN LISTS ZCONF_CONTENT) | ||
| 40 | if(FIRST_ITEM) | ||
| 41 | string(APPEND OUT_CONTENT ${item}) | ||
| 42 | set(FIRST_ITEM FALSE) | ||
| 43 | else(FIRST_ITEM) | ||
| 44 | string(APPEND OUT_CONTENT "\;" ${item}) | ||
| 45 | endif(FIRST_ITEM) | ||
| 46 | endforeach(item IN LISTS ${ZCONF_CONTENT}) | ||
| 47 | |||
| 48 | file(APPEND ${CONF_OUT_FILE} ${OUT_CONTENT}) | ||
| 49 | set(ZLIB_CONF_WRITTEN | ||
| 50 | TRUE | ||
| 51 | CACHE BOOL "zconf.h.cmakein was created") | ||
| 52 | mark_as_advanced(ZLIB_CONF_WRITTEN) | ||
| 53 | endif(NOT ZLIB_CONF_WRITTEN) | ||
| 54 | |||
| 55 | if(ENABLE_BZIP2) | ||
| 56 | find_package(BZip2 REQUIRED) | ||
| 57 | endif(ENABLE_BZIP2) | ||
| 58 | |||
| 59 | # | ||
| 60 | # Check for fopen64 | ||
| 61 | # | ||
| 62 | check_function_exists(fopen64 HAVE_FOPEN64) | ||
| 63 | |||
| 64 | # | ||
| 65 | # Check to see if we have large file support | ||
| 66 | # | ||
| 67 | set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1) | ||
| 68 | check_type_size(off64_t OFF64_T) | ||
| 69 | unset(CMAKE_REQUIRED_DEFINITIONS) # clear variable | ||
| 70 | |||
| 71 | # | ||
| 72 | # Check for fseeko | ||
| 73 | # | ||
| 74 | check_function_exists(fseeko HAVE_FSEEKO) | ||
| 75 | |||
| 76 | # | ||
| 77 | # Check for stdarg.h | ||
| 78 | # | ||
| 79 | check_include_file(stdarg.h HAVE_STDARG_H) | ||
| 80 | |||
| 81 | # | ||
| 82 | # Check for unistd.h | ||
| 83 | # | ||
| 84 | check_include_file(unistd.h HAVE_UNISTD_H) | ||
| 85 | |||
| 86 | # | ||
| 87 | # Check visibility attribute is supported | ||
| 88 | # | ||
| 89 | if(MSVC) | ||
| 90 | set(CMAKE_REQUIRED_FLAGS "-WX") | ||
| 91 | else(MSVC) | ||
| 92 | set(CMAKE_REQUIRED_FLAGS "-Werror") | ||
| 93 | endif(MSVC) | ||
| 94 | |||
| 95 | check_c_source_compiles( | ||
| 96 | " | ||
| 97 | #include <stdlib.h> | ||
| 98 | static void f(void) __attribute__ ((visibility(\"hidden\"))); | ||
| 99 | int main(void) {return 0;} | ||
| 100 | " | ||
| 101 | HAVE___ATTR__VIS_HIDDEN) | ||
| 102 | |||
| 103 | unset(CMAKE_COMPILE_FLAGS) | ||
| 104 | configure_file(${zlib1-dll_BINARY_DIR}/zconf.h.cmakein ${zlib1-dll_BINARY_DIR}/zconf.h) | ||
| 105 | |||
| 106 | # ============================================================================ | ||
| 107 | # zlib1-dll | ||
| 108 | # ============================================================================ | ||
| 109 | set(ZLIB1-DLL_PUBLIC_HDRS | ||
| 110 | ${zlib1-dll_BINARY_DIR}/zconf.h | ||
| 111 | ../../zlib.h | ||
| 112 | ../minizip/crypt.h | ||
| 113 | ../minizip/ints.h | ||
| 114 | ../minizip/ioapi.h | ||
| 115 | ../minizip/mztools.h | ||
| 116 | ../minizip/unzip.h | ||
| 117 | ../minizip/zip.h) | ||
| 118 | |||
| 119 | set(ZLIB1-DLL_PRIVATE_HDRS | ||
| 120 | ../../crc32.h | ||
| 121 | ../../deflate.h | ||
| 122 | ../../gzguts.h | ||
| 123 | ../../inffast.h | ||
| 124 | ../../inffixed.h | ||
| 125 | ../../inflate.h | ||
| 126 | ../../inftrees.h | ||
| 127 | ../../trees.h | ||
| 128 | ../../zutil.h) | ||
| 129 | |||
| 130 | set(ZLIB1-DLL_SRCS | ||
| 131 | ../../adler32.c | ||
| 132 | ../../compress.c | ||
| 133 | ../../crc32.c | ||
| 134 | ../../deflate.c | ||
| 135 | ../../gzclose.c | ||
| 136 | ../../gzlib.c | ||
| 137 | ../../gzread.c | ||
| 138 | ../../gzwrite.c | ||
| 139 | ../../inflate.c | ||
| 140 | ../../infback.c | ||
| 141 | ../../inftrees.c | ||
| 142 | ../../inffast.c | ||
| 143 | ../../trees.c | ||
| 144 | ../../uncompr.c | ||
| 145 | ../../win32/zlib1.rc | ||
| 146 | ../../zutil.c | ||
| 147 | ../minizip/ioapi.c | ||
| 148 | ../minizip/mztools.c | ||
| 149 | ../minizip/unzip.c | ||
| 150 | ../minizip/zip.c) | ||
| 151 | |||
| 152 | add_library(zlib1 SHARED ${ZLIB1-DLL_SRCS} | ||
| 153 | ${ZLIB1-DLL_PUBLIC_HDRS} | ||
| 154 | ${ZLIB1-DLL_PRIVATE_HDRS}) | ||
| 155 | |||
| 156 | #taget_include_directories doesn't like relative paths | ||
| 157 | include_directories(../../ | ||
| 158 | ../minizip | ||
| 159 | ${CMAKE_CURRENT_BINARY_DIR}) | ||
| 160 | |||
| 161 | target_compile_definitions(zlib1 | ||
| 162 | PRIVATE ZLIB_BUILD | ||
| 163 | $<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO> | ||
| 164 | $<$<BOOL:${HAVE_UNISTD_H}>:HAVE_UNISTD_H=1> | ||
| 165 | $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN> | ||
| 166 | $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE> | ||
| 167 | $<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE> | ||
| 168 | PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1> | ||
| 169 | $<$<BOOL:${BZIP2_FOUND}>:HAVE_BZIP2=1> | ||
| 170 | $<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>) | ||
| 171 | |||
| 172 | target_link_libraries(zlib1 | ||
| 173 | PUBLIC $<$<BOOL:${BZIP2_FOUND}>:BZip2::BZip2>) | ||
| 174 | |||
| 175 | if(NOT CYGWIN) | ||
| 176 | set_target_properties(zlib1 PROPERTIES | ||
| 177 | SOVERSION ${zlib1-dll_VERSION_MAJOR} | ||
| 178 | VERSION ${zlib1-dll_VERSION}) | ||
| 179 | endif(NOT CYGWIN) | ||
| 180 | |||
| 181 | set_target_properties(zlib1 PROPERTIES | ||
| 182 | DEFINE_SYMBOL ZLIB_DLL) | ||
| 183 | |||
| 184 | install( | ||
| 185 | TARGETS zlib1 | ||
| 186 | ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" | ||
| 187 | RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" | ||
| 188 | LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") | ||
| 189 | |||
| 190 | install( | ||
| 191 | FILES ${ZLIB1-DLL_PUBLIC_HDRS} | ||
| 192 | DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") | ||
| 193 | |||
| 194 | install( | ||
| 195 | FILES ../../LICENSE | ||
| 196 | DESTINATION "${CMAKE_INSTALL_DOCDIR}/zlib1-dll") | ||
diff --git a/contrib/zlib1-dll/readme.txt b/contrib/zlib1-dll/readme.txt new file mode 100644 index 00000000..eccb6ca3 --- /dev/null +++ b/contrib/zlib1-dll/readme.txt | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | Use this directory to build the legacy zlib1.dll for Windows, which contains | ||
| 2 | both zlib and minizip. Use cmake either at the command prompt, or with Visual | ||
| 3 | Studio as outlined below. | ||
| 4 | |||
| 5 | |||
| 6 | To create a Visual Studio project | ||
| 7 | --------------------------------- | ||
| 8 | |||
| 9 | 1. Start cmake-gui. | ||
| 10 | 2. Point source-dir to the source. | ||
| 11 | 3. Point build-dir to the dir where you want to build. | ||
| 12 | 4. Hit configure -- there you can select details. | ||
| 13 | 5. Select the options you want, which are shown with descriptions after the | ||
| 14 | configure run is complete. | ||
| 15 | 6. Hit configure again to assure that everything that is needed is found. | ||
| 16 | 7. For those not found, deactivate the option or install the dependency, e.g. | ||
| 17 | bzip2 for minizip, and go back to step 6 until there is no red. | ||
| 18 | 8. Hit generate. | ||
| 19 | 9. Hit open project. | ||
| 20 | |||
| 21 | Now you can Build > Build solution. | ||
