@@ -21,7 +21,6 @@ check_include_file(stddef.h HAVE_STDDEF_H)
2121# Check to see if we have large file support
2222#
2323set (CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE)
24-
2524# We add these other definitions here because CheckTypeSize.cmake
2625# in CMake 2.4.x does not automatically do so and we want
2726# compatibility with CMake 2.4.x.
@@ -34,9 +33,7 @@ endif()
3433if (HAVE_STDDEF_H)
3534 list (APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
3635endif ()
37-
3836check_type_size(off64_t OFF64_T)
39-
4037if (HAVE_OFF64_T)
4138 add_definitions (-D_LARGEFILE64_SOURCE)
4239endif ()
@@ -62,23 +59,6 @@ if(NOT HAVE_ERRNO_H)
6259 add_definitions (-DNO_ERRNO_H)
6360endif ()
6461
65- #
66- # Check for mmap support
67- #
68- set (mmap_test_code "
69- #include <sys/types.h>
70- #include <sys/mman.h>
71- #include <sys/stat.h>
72- caddr_t hello() {
73- return mmap((caddr_t)0, (off_t)0, PROT_READ, MAP_SHARED, 0, (off_t)0);
74- }
75- int main() { return 0; }
76- " )
77- check_c_source_compiles("${mmap_test_code} " USE_MMAP)
78- if (USE_MMAP)
79- add_definitions (-DUSE_MMAP)
80- endif ()
81-
8262#
8363# Create the zlibdefs.h file.
8464# Note: we create it in CMAKE_CURRENT_SOURCE_DIR instead
@@ -88,7 +68,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zlibdefs.h.cmakein
8868 ${CMAKE_CURRENT_SOURCE_DIR} /zlibdefs.h)
8969
9070if (MSVC )
91- set (CMAKE_DEBUG_POSTFIX "D " )
71+ set (CMAKE_DEBUG_POSTFIX "d " )
9272 add_definitions (-D_CRT_SECURE_NO_DEPRECATE)
9373 add_definitions (-D_CRT_NONSTDC_NO_DEPRECATE)
9474endif ()
@@ -130,15 +110,47 @@ set(ZLIB_SRCS
130110 trees.c
131111 uncompr.c
132112 zutil.c
113+ win32 /zlib1.rc
133114)
134115
116+ # parse the full version number from zlib.h and include in ZLIB_FULL_VERSION
117+ file (READ ${CMAKE_CURRENT_SOURCE_DIR} /zlib.h _zlib_h_contents)
118+ string (REGEX REPLACE ".*#define[ \t ]+ZLIB_VERSION[ \t ]+\" ([0-9A-Za-z.]+)\" .*"
119+ "\\ 1" ZLIB_FULL_VERSION ${_zlib_h_contents} )
120+
121+ if (MINGW)
122+ # This gets us DLL resource information when compiling on MinGW.
123+ add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR} /zlib1rc.obj
124+ COMMAND windres.exe
125+ -D GCC_WINDRES
126+ -I ${CMAKE_CURRENT_SOURCE_DIR}
127+ -o ${CMAKE_CURRENT_BINARY_DIR} /zlib1rc.obj
128+ -i ${CMAKE_CURRENT_SOURCE_DIR} /win32 /zlib1.rc)
129+ set (ZLIB_SRCS ${ZLIB_SRCS} ${CMAKE_CURRENT_BINARY_DIR} /zlib1rc.obj)
130+ endif (MINGW)
131+
135132add_library (zlib ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS} )
136133set_target_properties (zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
137- set_target_properties (zlib PROPERTIES VERSION 1.2.3.4)
134+
138135set_target_properties (zlib PROPERTIES SOVERSION 1)
136+
137+ if (NOT CYGWIN )
138+ # This property causes shared libraries on Linux to have the full version
139+ # encoded into their final filename. We disable this on Cygwin because
140+ # it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll
141+ # seems to be the default.
142+ #
143+ # This has no effect with MSVC, on that platform the version info for
144+ # the DLL comes from the resource file win32/zlib1.rc
145+ set_target_properties (zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION} )
146+ endif ()
147+
139148if (UNIX )
140- # On unix like platforms the library is almost always called libz
149+ # On unix- like platforms the library is almost always called libz
141150 set_target_properties (zlib PROPERTIES OUTPUT_NAME z)
151+ elseif (BUILD_SHARED_LIBS AND WIN32 )
152+ # Creates zlib1.dll when building shared library version
153+ set_target_properties (zlib PROPERTIES SUFFIX "1.dll" )
142154endif ()
143155
144156if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
0 commit comments