From 3909c238177651ca7e6fe194cf41d522acbee708 Mon Sep 17 00:00:00 2001 From: Andy Maloney Date: Tue, 22 May 2018 09:02:09 -0400 Subject: [PATCH] Partial fix for building without zlib (See issue nmoinvaz/minizip#264) --- CMakeLists.txt | 6 ++++-- mz_zip.c | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb5272d..2853dac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,7 +58,6 @@ set(MINIZIP_SRC mz_strm_mem.c mz_strm_posix.c mz_strm_split.c - mz_strm_zlib.c mz_zip.c) set(MINIZIP_PUBLIC_HEADERS @@ -70,7 +69,6 @@ set(MINIZIP_PUBLIC_HEADERS mz_strm_mem.h mz_strm_posix.h mz_strm_split.h - mz_strm_zlib.h mz_zip.h) if(WIN32) @@ -156,6 +154,9 @@ endif() if(USE_ZLIB) add_definitions(-DHAVE_ZLIB) + list(APPEND MINIZIP_SRC "mz_strm_zlib.c") + list(APPEND MINIZIP_PUBLIC_HEADERS "mz_strm_zlib.h") + include(CheckFunctionExists) set(CMAKE_REQUIRED_LIBRARIES ZLIB::ZLIB) CHECK_FUNCTION_EXISTS(z_get_crc_table @@ -165,6 +166,7 @@ if(USE_ZLIB) add_definitions(-DZ_PREFIX) endif() endif() + if(USE_BZIP2) add_definitions(-DHAVE_BZIP2) add_definitions(-DBZ_NO_STDIO) diff --git a/mz_zip.c b/mz_zip.c index fc00c50..e022b4c 100644 --- a/mz_zip.c +++ b/mz_zip.c @@ -1158,8 +1158,10 @@ static int32_t mz_zip_entry_open_int(void *handle, int16_t compression_method, i { if (zip->compression_method == MZ_COMPRESS_METHOD_RAW) mz_stream_raw_create(&zip->compress_stream); +#ifdef HAVE_ZLIB else if (zip->compression_method == MZ_COMPRESS_METHOD_DEFLATE) mz_stream_zlib_create(&zip->compress_stream); +#endif #ifdef HAVE_BZIP2 else if (zip->compression_method == MZ_COMPRESS_METHOD_BZIP2) mz_stream_bzip_create(&zip->compress_stream);