Build with minizip-ng instead of minizip or libzip

https://github.com/zlib-ng/minizip-ng
This commit is contained in:
Jörg Bakker 2022-11-01 17:51:14 +01:00
parent 47fd7b9640
commit 59fc5b0a0f
3 changed files with 32 additions and 11 deletions

View File

@ -22,6 +22,7 @@ OPTION(BUILD_PC_FILES "Build pkg-config .pc" ON)
OPTION(BUILD_TOOLS "Build tools" ON)
OPTION(BUILD_EXAMPLES "Build examples" ON)
OPTION(WITH_LIBZIP "Use libzip instead of Minizip" OFF)
OPTION(WITH_MINIZIP_NG "Use Minizip NG" OFF)
OPTION(WITH_WIDE "Also build UTF-16 library (libxlsxio_readw)" OFF)
SET(ZLIB_DIR "" CACHE PATH "Path to the zlib library")
IF(WITH_LIBZIP)
@ -50,10 +51,19 @@ IF(WITH_LIBZIP)
SET(ANYZIP_LIBRARIES ${LIBZIP_LIBRARIES})
SET(ANYZIP_DEF USE_LIBZIP)
ELSE()
FIND_PACKAGE(Minizip REQUIRED)
SET(ANYZIP_INCLUDE_DIRS ${MINIZIP_INCLUDE_DIRS})
SET(ANYZIP_LIBRARIES ${MINIZIP_LIBRARIES})
SET(ANYZIP_DEF USE_MINIZIP)
SET(USE_MINIZIP)
ADD_DEFINITIONS(-DUSE_MINIZIP)
SET(ANYZIP_DEF)
IF(WITH_MINIZIP_NG)
FIND_PACKAGE(minizip REQUIRED)
SET(USE_MINIZIP_NG)
ADD_DEFINITIONS(-DUSE_MINIZIP_NG)
SET(ANYZIP_LIBRARIES MINIZIP::minizip)
ELSE()
FIND_PACKAGE(Minizip REQUIRED)
SET(ANYZIP_INCLUDE_DIRS ${MINIZIP_INCLUDE_DIRS})
SET(ANYZIP_LIBRARIES ${MINIZIP_LIBRARIES})
ENDIF()
ENDIF()
# dependancy: expat
IF(EXPAT_DIR)

View File

@ -8,8 +8,12 @@
#include <string.h>
#include <expat.h>
#ifdef USE_MINIZIP
# include <minizip/unzip.h>
#if (defined(USE_MINIZIP)) || (defined(USE_MINIZIP_NG))
# ifdef USE_MINIZIP_NG
# include <mz_compat.h>
# else
# include <minizip/unzip.h>
# endif
# define ZIPFILETYPE unzFile
# define ZIPFILEENTRYTYPE unzFile
# if defined(_MSC_VER)
@ -21,15 +25,15 @@
# define IOSIZETYPE ssize_t
# define IOFN(fn) fn
# endif
/*
# if !defined(Z_DEFLATED) && defined(MZ_COMPRESS_METHOD_DEFLATE) // support minizip2 which defines MZ_COMPRESS_METHOD_DEFLATE instead of Z_DEFLATED
# if defined(MZ_COMPRESS_METHOD_DEFLATE) // support minizip2 which defines MZ_COMPRESS_METHOD_DEFLATE instead of Z_DEFLATED
# ifndef ZCALLBACK
# define ZCALLBACK
# endif
# define voidpf void*
# define uLong unsigned long
# endif
*/
#else
# if (defined(STATIC) || defined(BUILD_XLSXIO_STATIC) || defined(BUILD_XLSXIO_STATIC_DLL) || (defined(BUILD_XLSXIO) && !defined(BUILD_XLSXIO_DLL) && !defined(BUILD_XLSXIO_SHARED))) && !defined(ZIP_STATIC)
# define ZIP_STATIC

View File

@ -11,12 +11,19 @@
#include <fcntl.h>
#include <stdarg.h>
#ifdef USE_MINIZIP
# include <minizip/zip.h>
#if (defined(USE_MINIZIP)) || (defined(USE_MINIZIP_NG))
# ifdef USE_MINIZIP_NG
# include <mz_compat.h>
# else
# include <minizip/unzip.h>
# endif
# if !defined(Z_DEFLATED) && defined(MZ_COMPRESS_METHOD_DEFLATE) /* support minizip2 which defines MZ_COMPRESS_METHOD_DEFLATE instead of Z_DEFLATED */
# define Z_DEFLATED MZ_COMPRESS_METHOD_DEFLATE
# endif
# define ZIPFILETYPE zipFile
#elif USE_MINIZIP_NG
# include <mz_compat.h>
# define ZIPFILETYPE zipFile
#else
# if (defined(STATIC) || defined(BUILD_XLSXIO_STATIC) || defined(BUILD_XLSXIO_STATIC_DLL) || (defined(BUILD_XLSXIO) && !defined(BUILD_XLSXIO_DLL) && !defined(BUILD_XLSXIO_SHARED))) && !defined(ZIP_STATIC)
# define ZIP_STATIC