Commit 2b64394 for zlib
commit 2b643940a7b731372ee3339d822a2ad7e3d91ff0
Author: Mark Adler <git@madler.net>
Date: Fri Nov 6 11:25:33 2026 -0800
Compile the CMake static library as position-independent code.
Make cmake consistent with configure in compiling static libraries
using position-independent code. CMAKE_POSITION_INDEPENDENT_CODE
OFF is honored if that is needed.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index da75888..f03664e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -337,6 +337,13 @@ if(ZLIB_BUILD_STATIC)
PROPERTIES
EXPORT_NAME ZLIBSTATIC
PUBLIC_HEADER "${ZLIB_PUBLIC_HDRS}")
+
+ if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
+ set_target_properties(zlibstatic
+ PROPERTIES
+ POSITION_INDEPENDENT_CODE ON)
+ endif(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
+
endif(ZLIB_BUILD_STATIC)
if(ZLIB_INSTALL)