diff --git a/CMakeLists.txt b/CMakeLists.txt index afdc9bc..f0a6703 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/lib/xlsxio_read.c b/lib/xlsxio_read.c index a08085c..78bd9b9 100644 --- a/lib/xlsxio_read.c +++ b/lib/xlsxio_read.c @@ -8,8 +8,12 @@ #include #include -#ifdef USE_MINIZIP -# include +#if (defined(USE_MINIZIP)) || (defined(USE_MINIZIP_NG)) +# ifdef USE_MINIZIP_NG +# include +# else +# include +# 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 diff --git a/lib/xlsxio_write.c b/lib/xlsxio_write.c index 464390d..afaed5c 100644 --- a/lib/xlsxio_write.c +++ b/lib/xlsxio_write.c @@ -11,12 +11,19 @@ #include #include -#ifdef USE_MINIZIP -# include +#if (defined(USE_MINIZIP)) || (defined(USE_MINIZIP_NG)) +# ifdef USE_MINIZIP_NG +# include +# else +# include +# 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 +# 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