From 07f8c37fb7f79364e74d41cc136e5ce435938bc8 Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Fri, 7 Jun 2024 10:06:03 -0700 Subject: [PATCH] update(cmake): Build zlib using CMake on Windows Build zlib using CMake on Windows instead of nmake. The nmakefile passes "-base:0x5A4C0000" to the linker, which is too small on Arm64 and not really needed or wanted on any platform these days. https://github.com/madler/zlib/issues/325 Signed-off-by: Gerald Combs --- cmake/modules/zlib.cmake | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmake/modules/zlib.cmake b/cmake/modules/zlib.cmake index c947f897bb..872e4455d8 100644 --- a/cmake/modules/zlib.cmake +++ b/cmake/modules/zlib.cmake @@ -73,19 +73,21 @@ else() else() if(BUILD_SHARED_LIBS) set(ZLIB_LIB_SUFFIX "${CMAKE_SHARED_LIBRARY_SUFFIX}") + set(ZLIB_LIB "${ZLIB_SRC}/lib/zlib${ZLIB_LIB_SUFFIX}") else() set(ZLIB_LIB_SUFFIX "${CMAKE_STATIC_LIBRARY_SUFFIX}") + set(ZLIB_LIB "${ZLIB_SRC}/lib/zlibstatic${ZLIB_LIB_SUFFIX}") endif() - set(ZLIB_LIB "${ZLIB_SRC}/zlib${ZLIB_LIB_SUFFIX}") ExternalProject_Add(zlib PREFIX "${PROJECT_BINARY_DIR}/zlib-prefix" URL "https://github.com/madler/zlib/archive/v1.2.13.tar.gz" URL_HASH "SHA256=1525952a0a567581792613a9723333d7f8cc20b87a81f920fb8bc7e3f2251428" - CONFIGURE_COMMAND "" - BUILD_COMMAND nmake -f win32/Makefile.msc LOC="\"${ZLIB_CFLAGS} -DZLIB_WINAPI\"" BUILD_IN_SOURCE 1 BUILD_BYPRODUCTS ${ZLIB_LIB} - INSTALL_COMMAND "") + CMAKE_ARGS + -DCMAKE_POSITION_INDEPENDENT_CODE=${ENABLE_PIC} + -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} + -DCMAKE_INSTALL_PREFIX=${ZLIB_SRC}) install(FILES "${ZLIB_LIB}" DESTINATION "${CMAKE_INSTALL_LIBDIR}/${LIBS_PACKAGE_NAME}" COMPONENT "libs-deps") install(FILES ${ZLIB_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBS_PACKAGE_NAME}/zlib"