Skip to content

Commit

Permalink
update(cmake): Build zlib using CMake on Windows
Browse files Browse the repository at this point in the history
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.

madler/zlib#325

Signed-off-by: Gerald Combs <[email protected]>
  • Loading branch information
geraldcombs committed Jun 7, 2024
1 parent 40c0792 commit 91eb837
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cmake/modules/zlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 91eb837

Please sign in to comment.