Skip to content

Commit 5c57f6a

Browse files
committed
build: Add auto-build recipe for ZLIB (AcademySoftwareFoundation#4420)
Required for building redistributable python wheels on Windows Wheels runners. Signed-off-by: Zach Lewis <zachcanbereached@gmail.com>
1 parent b21afd5 commit 5c57f6a

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/cmake/build_ZLIB.cmake

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright Contributors to the OpenImageIO project.
2+
# SPDX-License-Identifier: Apache-2.0
3+
# https://github.com/AcademySoftwareFoundation/OpenImageIO
4+
5+
######################################################################
6+
# ZLIB by hand!
7+
######################################################################
8+
9+
set_cache (ZLIB_BUILD_VERSION 1.3.1 "ZLIB version for local builds")
10+
set (ZLIB_GIT_REPOSITORY "https://github.com/madler/zlib")
11+
set (ZLIB_GIT_TAG "v${ZLIB_BUILD_VERSION}")
12+
13+
set_cache (ZLIB_BUILD_SHARED_LIBS ${LOCAL_BUILD_SHARED_LIBS_DEFAULT}
14+
DOC "Should execute a local ZLIB build, if necessary, build shared libraries" ADVANCED)
15+
16+
string (MAKE_C_IDENTIFIER ${ZLIB_BUILD_VERSION} ZLIB_VERSION_IDENT)
17+
18+
build_dependency_with_cmake(ZLIB
19+
VERSION ${ZLIB_BUILD_VERSION}
20+
GIT_REPOSITORY ${ZLIB_GIT_REPOSITORY}
21+
GIT_TAG ${ZLIB_GIT_TAG}
22+
CMAKE_ARGS
23+
-D BUILD_SHARED_LIBS=${ZLIB_BUILD_SHARED_LIBS}
24+
-D CMAKE_POSITION_INDEPENDENT_CODE=ON
25+
-D CMAKE_INSTALL_LIBDIR=lib
26+
)
27+
28+
# Set some things up that we'll need for a subsequent find_package to work
29+
set (ZLIB_ROOT ${ZLIB_LOCAL_INSTALL_DIR})
30+
31+
# Signal to caller that we need to find again at the installed location
32+
set (ZLIB_REFIND TRUE)
33+
set (ZLIB_VERSION ${ZLIB_BUILD_VERSION})
34+
set (ZLIB_REFIND_VERSION ${ZLIB_BUILD_VERSION})
35+
36+
if (ZLIB_BUILD_SHARED_LIBS)
37+
install_local_dependency_libs (ZLIB ZLIB)
38+
endif ()

0 commit comments

Comments
 (0)