diff --git a/setup.py b/setup.py
index fbd23a5685a..129dab6f1c4 100644
--- a/setup.py
+++ b/setup.py
@@ -689,10 +689,15 @@ def build_extensions(self) -> None:
if _find_include_file(self, "zlib.h"):
if _find_library_file(self, "z"):
feature.set("zlib", "z")
- elif sys.platform == "win32" and _find_library_file(self, "zlib"):
- feature.set("zlib", "zlib") # alternative name
- elif sys.platform == "win32" and _find_library_file(self, "zdll"):
- feature.set("zlib", "zdll") # dll import library
+ elif sys.platform == "win32":
+ for library in (
+ "zlib",
+ "zlibstatic",
+ "zdll", # dll import library
+ ):
+ if _find_library_file(self, library):
+ feature.set("zlib", library)
+ break
if feature.want("jpeg"):
_dbg("Looking for jpeg")
diff --git a/winbuild/build_prepare.py b/winbuild/build_prepare.py
index 9ab04f7e5e4..f9c8c14cdf2 100644
--- a/winbuild/build_prepare.py
+++ b/winbuild/build_prepare.py
@@ -163,18 +163,13 @@ def cmd_msbuild(
"filename": f"zlib-ng-{V['ZLIBNG']}.zip",
"dir": f"zlib-ng-{V['ZLIBNG']}",
"license": "LICENSE.md",
- "patch": {
- r"CMakeLists.txt": {
- "set_target_properties(zlib PROPERTIES OUTPUT_NAME zlibstatic${{SUFFIX}})": "set_target_properties(zlib PROPERTIES OUTPUT_NAME zlib)", # noqa: E501
- },
- },
"build": [
*cmds_cmake(
"zlib", "-DBUILD_SHARED_LIBS:BOOL=OFF", "-DZLIB_COMPAT:BOOL=ON"
),
],
"headers": [r"z*.h"],
- "libs": [r"zlib.lib"],
+ "libs": ["zlibstatic.lib"],
},
"xz": {
"url": f"https://github.com/tukaani-project/xz/releases/download/v{V['XZ']}/FILENAME",
@@ -285,7 +280,7 @@ def cmd_msbuild(
"": "FT_CONFIG_OPTION_SYSTEM_ZLIB;FT_CONFIG_OPTION_USE_PNG;FT_CONFIG_OPTION_USE_HARFBUZZ;FT_CONFIG_OPTION_USE_BROTLI", # noqa: E501
"": r"{dir_harfbuzz}\src;{inc_dir}", # noqa: E501
"": "{lib_dir}", # noqa: E501
- "": f"zlib.lib;libpng{V['LIBPNG_XY']}.lib;brotlicommon.lib;brotlidec.lib", # noqa: E501
+ "": f"zlibstatic.lib;libpng{V['LIBPNG_XY']}.lib;brotlicommon.lib;brotlidec.lib", # noqa: E501
},
r"src/autofit/afshaper.c": {
# link against harfbuzz.lib