Skip to content

Commit 514ef50

Browse files
committed
Fix build under MSYS2.
1 parent 9363966 commit 514ef50

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ CMakeCache.txt
3737
CMakeFiles
3838
Testing
3939
*.cmake
40+
*.stackdump
4041
zconf.h
4142
zconf.h.cmakein
4243
zconf.h.included

CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ endif()
5858
check_type_size(off64_t OFF64_T)
5959
if(HAVE_OFF64_T)
6060
add_definitions(-D_LARGEFILE64_SOURCE=1)
61+
else()
62+
check_type_size(_off64_t _OFF64_T)
63+
if (HAVE__OFF64_T)
64+
add_definitions(-D_LARGEFILE64_SOURCE=1)
65+
endif()
6166
endif()
6267
set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
6368

@@ -170,7 +175,7 @@ else (WITH_GZFILEOP)
170175
endif (WITH_GZFILEOP)
171176

172177

173-
if(NOT MINGW)
178+
if(NOT MINGW AND NOT MSYS)
174179
set(ZLIB_DLL_SRCS
175180
win32/zlib1.rc # If present will override custom build rule below.
176181
)
@@ -181,7 +186,7 @@ file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents)
181186
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
182187
"\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})
183188

184-
if(MINGW)
189+
if(MINGW OR MSYS)
185190
# This gets us DLL resource information when compiling on MinGW.
186191
if(NOT CMAKE_RC_COMPILER)
187192
set(CMAKE_RC_COMPILER windres.exe)
@@ -195,7 +200,7 @@ if(MINGW)
195200
-o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
196201
-i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
197202
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
198-
endif(MINGW)
203+
endif(MINGW OR MSYS)
199204

200205
add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_GZFILE_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
201206
add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_GZFILE_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})

configure

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,9 @@ echo >> configure.log
455455
# check for large file support, and if none, check for fseeko()
456456
cat > $test.c <<EOF
457457
#include <sys/types.h>
458+
#ifdef __MSYS__
459+
# define off64_t _off64_t
460+
#endif
458461
off64_t dummy = 0;
459462
EOF
460463
if try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then

zconf.h.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ typedef void *voidp;
164164
#if !defined(WIN32) && defined(Z_LARGE64)
165165
# define z_off64_t off64_t
166166
#else
167-
# if defined(WIN32) && !defined(__GNUC__)
167+
# if defined(__MSYS__)
168+
# define z_off64_t _off64_t
169+
# elif defined(WIN32) && !defined(__GNUC__)
168170
# define z_off64_t __int64
169171
# else
170172
# define z_off64_t z_off_t

zutil.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
7979
#endif
8080

8181
/* provide prototypes for these when building zlib without LFS */
82-
#if !defined(WIN32) && (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
82+
#if !defined(WIN32) && !defined(__MSYS__) && (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
8383
ZEXTERN uint32_t ZEXPORT adler32_combine64(uint32_t, uint32_t, z_off_t);
8484
ZEXTERN uint32_t ZEXPORT crc32_combine64(uint32_t, uint32_t, z_off_t);
8585
#endif

0 commit comments

Comments
 (0)