Partial fix for building without zlib

(See issue nmoinvaz/minizip#264)
This commit is contained in:
Andy Maloney 2018-05-22 09:02:09 -04:00
parent e1aad8c445
commit 3909c23817
2 changed files with 6 additions and 2 deletions

View File

@ -58,7 +58,6 @@ set(MINIZIP_SRC
mz_strm_mem.c mz_strm_mem.c
mz_strm_posix.c mz_strm_posix.c
mz_strm_split.c mz_strm_split.c
mz_strm_zlib.c
mz_zip.c) mz_zip.c)
set(MINIZIP_PUBLIC_HEADERS set(MINIZIP_PUBLIC_HEADERS
@ -70,7 +69,6 @@ set(MINIZIP_PUBLIC_HEADERS
mz_strm_mem.h mz_strm_mem.h
mz_strm_posix.h mz_strm_posix.h
mz_strm_split.h mz_strm_split.h
mz_strm_zlib.h
mz_zip.h) mz_zip.h)
if(WIN32) if(WIN32)
@ -156,6 +154,9 @@ endif()
if(USE_ZLIB) if(USE_ZLIB)
add_definitions(-DHAVE_ZLIB) add_definitions(-DHAVE_ZLIB)
list(APPEND MINIZIP_SRC "mz_strm_zlib.c")
list(APPEND MINIZIP_PUBLIC_HEADERS "mz_strm_zlib.h")
include(CheckFunctionExists) include(CheckFunctionExists)
set(CMAKE_REQUIRED_LIBRARIES ZLIB::ZLIB) set(CMAKE_REQUIRED_LIBRARIES ZLIB::ZLIB)
CHECK_FUNCTION_EXISTS(z_get_crc_table CHECK_FUNCTION_EXISTS(z_get_crc_table
@ -165,6 +166,7 @@ if(USE_ZLIB)
add_definitions(-DZ_PREFIX) add_definitions(-DZ_PREFIX)
endif() endif()
endif() endif()
if(USE_BZIP2) if(USE_BZIP2)
add_definitions(-DHAVE_BZIP2) add_definitions(-DHAVE_BZIP2)
add_definitions(-DBZ_NO_STDIO) add_definitions(-DBZ_NO_STDIO)

View File

@ -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) if (zip->compression_method == MZ_COMPRESS_METHOD_RAW)
mz_stream_raw_create(&zip->compress_stream); mz_stream_raw_create(&zip->compress_stream);
#ifdef HAVE_ZLIB
else if (zip->compression_method == MZ_COMPRESS_METHOD_DEFLATE) else if (zip->compression_method == MZ_COMPRESS_METHOD_DEFLATE)
mz_stream_zlib_create(&zip->compress_stream); mz_stream_zlib_create(&zip->compress_stream);
#endif
#ifdef HAVE_BZIP2 #ifdef HAVE_BZIP2
else if (zip->compression_method == MZ_COMPRESS_METHOD_BZIP2) else if (zip->compression_method == MZ_COMPRESS_METHOD_BZIP2)
mz_stream_bzip_create(&zip->compress_stream); mz_stream_bzip_create(&zip->compress_stream);