From: Michihiro NAKAJIMA Date: Mon, 12 Sep 2011 07:39:51 +0000 (-0400) Subject: Issue 182. X-Git-Tag: v3.0.0a~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=049631350f291eb52e23a86d16bebbcbe377aa38;p=thirdparty%2Flibarchive.git Issue 182. 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 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index fd8b38164..72b8a5221 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 \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) diff --git a/build/cmake/config.h.in b/build/cmake/config.h.in index 39673494e..4e9b074b2 100644 --- a/build/cmake/config.h.in +++ b/build/cmake/config.h.in @@ -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 diff --git a/libarchive/archive_windows.h b/libarchive/archive_windows.h index 385cb4d98..dc2ba00da 100644 --- a/libarchive/archive_windows.h +++ b/libarchive/archive_windows.h @@ -50,10 +50,6 @@ /* Start of configuration for native Win32 */ -#ifdef HAVE_ZLIB_H -#define ZLIB_WINAPI -#endif - #include #define set_errno(val) ((errno)=val) #include