# Find ZLIB
#
IF(ENABLE_ZLIB)
- FIND_PACKAGE(ZLIB)
+ # Require zlib >= 1.2.1, see: https://github.com/libarchive/libarchive/issues/615
+ # zlib 1.2.0 should also work, but it is difficult to test for. Let's require
+ # zlib >= 1.2.1 for consistency with the autoconf build.
+ FIND_PACKAGE(ZLIB 1.2.1 REQUIRED)
ELSE()
SET(ZLIB_FOUND FALSE) # Override cached value
ENDIF()
AS_HELP_STRING([--without-zlib], [Don't build support for gzip through zlib]))
if test "x$with_zlib" != "xno"; then
- AC_CHECK_HEADERS([zlib.h])
- AC_CHECK_LIB(z,inflate)
+ old_LIBS="$LIBS"
+ LIBS="$LIBS -lz"
+ AC_LINK_IFELSE([AC_LANG_SOURCE([[
+ #include <zlib.h>
+ #if !defined(ZLIB_VERNUM)
+ // zlib 1.2.0 should work too, but it's difficult to test for.
+ // zlib 1.2.1 onwards have ZLIB_VERNUM, which is easy to check.
+ #error zlib >= 1.2.1 is required.
+ #endif
+ // Check that there's an inflate function.
+ int main(int argc, char **argv) { inflate(NULL, 0); return 0; }
+ ]])],
+ [AC_DEFINE([HAVE_ZLIB_H], [1], [Define to 1 if you have zlib >= 1.2.1])
+ AC_MSG_RESULT([found a suitable version of zlib (>= 1.2.1)])
+ ],
+ [AC_MSG_RESULT([could not find a suitable version of zlib (>= 1.2.1)])
+ LIBS="$old_LIBS"])
fi
AC_ARG_WITH([bz2lib],