Decide whether ZLIB_WINAPI is needed at configuration time, because there are two types of zlib
on Windows platform: one is built on Visual Studio, which requires ZLIB_WINAPI for use; other is
build on msys, which does not require ZLIB_WINAPI, GnuWin32 project provide such zlib.
SVN-Revision: 3702
SET(HAVE_ZLIB_H 1)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
LIST(APPEND ADDITIONAL_LIBS ${ZLIB_LIBRARIES})
+ IF(WIN32 AND NOT CYGWIN)
+ SET(CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIR})
+ SET(CMAKE_REQUIRED_LIBRARIES ${ZLIB_LIBRARIES})
+ CHECK_C_SOURCE_Runs(
+ "#ifndef ZLIB_WINAPI\n#define ZLIB_WINAPI\n#endif\n#include <zlib.h>\nint main() {uLong f = zlibCompileFlags(); return (f&(1U<<10))?0:-1; }"
+ ZLIB_WINAPI)
+ ENDIF(WIN32 AND NOT CYGWIN)
ENDIF(ZLIB_FOUND)
MARK_AS_ADVANCED(CLEAR ZLIB_INCLUDE_DIR)
MARK_AS_ADVANCED(CLEAR ZLIB_LIBRARY)
typedef uint64_t uintmax_t;
#endif
+/* Define ZLIB_WINAPI if zlib was built on Visual Studio. */
+#cmakedefine ZLIB_WINAPI 1
+
/* MD5 via ARCHIVE_CRYPTO_MD5_LIBC supported. */
#cmakedefine ARCHIVE_CRYPTO_MD5_LIBC 1
/* Start of configuration for native Win32 */
-#ifdef HAVE_ZLIB_H
-#define ZLIB_WINAPI
-#endif
-
#include <errno.h>
#define set_errno(val) ((errno)=val)
#include <io.h>