vcpkg/ports/zlib/0003-build-static-or-shared-not-both.patch
Billy O'Neal e0a9559a9b
[zlib, minizip] Update to 1.2.13, and embed the ZLIB_DLL setting. (#27226)
* Don't use external ZLIB_DLL

* Update versions

* [minizip] Bump to zlib version

* Update versions

* [libkml] Fix mingw build

* [libkml] Modernize

* [libkml] Fix minizip dependency

* [libkml] No DLL

* Update versions

* [libkml] Update mingw patch

* Update versions

* Update versions

* [zlib] Update to 1.2.13

This picks up the official fix for CVE-2022-37434.

* Cherry pick installing the correct license from https://github.com/microsoft/vcpkg/pull/27242/

* Update version database.

* More version database.

* Also update minizip.

* Also guard ZLIB_DLL properties for BUILD_SHARED_LIBS.

* Version database.

* Fix minizip usage.

Co-authored-by: Kai Pastor <dg0yt@darc.de>
2022-10-25 10:24:48 -07:00

54 lines
2.0 KiB
Diff

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f46c8e6..6fa5575 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -121,9 +121,11 @@ set(ZLIB_SRCS
)
if(NOT MINGW)
+ if(BUILD_SHARED_LIBS)
set(ZLIB_DLL_SRCS
win32/zlib1.rc # If present will override custom build rule below.
)
+ endif()
endif()
# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION
@@ -144,13 +146,16 @@ if(MINGW)
-I ${CMAKE_CURRENT_BINARY_DIR}
-o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
-i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
+ if(BUILD_SHARED_LIBS)
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
+ endif()
endif(MINGW)
-add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
-add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
+add_library(zlib ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
+if (BUILD_SHARED_LIBS)
set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
set_target_properties(zlib PROPERTIES SOVERSION 1)
+endif()
if(NOT CYGWIN)
# This property causes shared libraries on Linux to have the full version
@@ -165,7 +170,7 @@ endif()
if(UNIX)
# On unix-like platforms the library is almost always called libz
- set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
+ set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
if(NOT APPLE)
set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
endif()
@@ -175,7 +180,7 @@ elseif(BUILD_SHARED_LIBS AND WIN32)
endif()
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
- install(TARGETS zlib zlibstatic
+ install(TARGETS zlib
RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )