]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Issue 182.
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Mon, 12 Sep 2011 07:39:51 +0000 (03:39 -0400)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Mon, 12 Sep 2011 07:39:51 +0000 (03:39 -0400)
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

CMakeLists.txt
build/cmake/config.h.in
libarchive/archive_windows.h

index fd8b38164f9b932215b6d2e3d80f2a7870b4e54f..72b8a52211679ba572479544d1e17a09617ce656 100644 (file)
@@ -179,6 +179,13 @@ IF(ZLIB_FOUND)
   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)
index 39673494eaefb43ec77b786425a4e63990660a64..4e9b074b29b24e2b62821b7ea8ac3ca853556055 100644 (file)
@@ -178,6 +178,9 @@ typedef int64_t intmax_t;
 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
 
index 385cb4d98eae61d3b6f13a1d9c46806784a89d12..dc2ba00daa6640fea6e0d5aea88e2b790a02c4fa 100644 (file)
 
 /* 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>