1- --- CMakeLists.txt 2022-10-13 06:06:55.000000000 +0100
2- +++ CMakeLists.txt 2022-10-13 06:06:55.000000000 +0100
3- @@ -147,8 +147,7 @@
1+ diff --git a/CMakeLists.txt b/CMakeLists.txt
2+ index 15ceebe..2f08574 100644
3+ --- CMakeLists.txt
4+ +++ CMakeLists.txt
5+ @@ -59,7 +59,6 @@ endif()
6+ check_include_file(unistd.h Z_HAVE_UNISTD_H)
7+
8+ if(MSVC)
9+ - set(CMAKE_DEBUG_POSTFIX "d")
10+ add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
11+ add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
12+ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
13+ @@ -122,7 +121,7 @@ set(ZLIB_SRCS
14+ zutil.c
15+ )
16+
17+ - if(NOT MINGW)
18+ + if(MSVC)
19+ set(ZLIB_DLL_SRCS
20+ win32/zlib1.rc # If present will override custom build rule below.
21+ )
22+ @@ -133,7 +132,7 @@ file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents)
23+ string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
24+ "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})
25+
26+ - if(MINGW)
27+ + if(WIN32 AND NOT MSVC)
28+ # This gets us DLL resource information when compiling on MinGW.
29+ if(NOT CMAKE_RC_COMPILER)
30+ set(CMAKE_RC_COMPILER windres.exe)
31+ @@ -147,14 +146,16 @@ if(MINGW)
32+ -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
33+ -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
434 set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
5- endif(MINGW)
35+ - endif(MINGW)
36+ + endif()
637
7- - add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
38+ + if(BUILD_SHARED_LIBS)
39+ add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
40+ target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
841- add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
9- + add_library(zlib ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS } ${ZLIB_PRIVATE_HDRS })
42+ - target_include_directories(zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR } ${CMAKE_CURRENT_SOURCE_DIR })
1043 set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
1144 set_target_properties(zlib PROPERTIES SOVERSION 1)
45+ + else()
46+ + add_library(zlib STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
47+ + endif()
1248
13- @@ -163,19 +162,18 @@
49+ if(NOT CYGWIN)
50+ # This property causes shared libraries on Linux to have the full version
51+ @@ -167,19 +168,25 @@ if(NOT CYGWIN)
1452 set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
1553 endif()
1654
1755- if(UNIX)
56+ + if(WIN32 AND NOT MINGW)
57+ + if(BUILD_SHARED_LIBS)
58+ + set_target_properties(zlib PROPERTIES ARCHIVE_OUTPUT_NAME zdll)
59+ + endif()
60+ + else()
1861 # On unix-like platforms the library is almost always called libz
1962- set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
20- - if(NOT APPLE)
2163+ set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
22- + if(UNIX AND NOT APPLE )
64+ if(NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX) )
2365 set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
2466 endif()
2567- elseif(BUILD_SHARED_LIBS AND WIN32)
68+ + endif()
2669+ if(BUILD_SHARED_LIBS AND WIN32)
2770 # Creates zlib1.dll when building shared library version
28- set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
71+ - set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
72+ + set_target_properties(zlib PROPERTIES PREFIX "" RUNTIME_OUTPUT_NAME "zlib1")
2973 endif()
3074
75+ +
3176 if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
3277- install(TARGETS zlib zlibstatic
3378+ install(TARGETS zlib
3479 RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
3580 ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
36- LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
81+ LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
0 commit comments