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)
4
34
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
5
- endif(MINGW)
35
+ - endif(MINGW)
36
+ + endif()
6
37
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})
8
41
- 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 })
10
43
set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
11
44
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()
12
48
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)
14
52
set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
15
53
endif()
16
54
17
55
- 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()
18
61
# On unix-like platforms the library is almost always called libz
19
62
- set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
20
- - if(NOT APPLE)
21
63
+ 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) )
23
65
set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
24
66
endif()
25
67
- elseif(BUILD_SHARED_LIBS AND WIN32)
68
+ + endif()
26
69
+ if(BUILD_SHARED_LIBS AND WIN32)
27
70
# 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")
29
73
endif()
30
74
75
+ +
31
76
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
32
77
- install(TARGETS zlib zlibstatic
33
78
+ install(TARGETS zlib
34
79
RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
35
80
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
36
- LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
81
+ LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
0 commit comments