Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix name of zlib that the linker needs #104904

Merged
merged 3 commits into from
Jul 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/native/libs/System.IO.Compression.Native/extra_libs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ macro(append_extra_compression_libs NativeLibsExtra)
# TODO: remove the mono-style HOST_ variable checks once Mono is using eng/native/configureplatform.cmake to define the CLR_CMAKE_TARGET_ defines
if (CLR_CMAKE_TARGET_BROWSER OR HOST_BROWSER OR CLR_CMAKE_TARGET_WASI OR HOST_WASI)
# nothing special to link
elseif (CLR_CMAKE_TARGET_ANDROID OR HOST_ANDROID)
# need special case here since we want to link against libz.so but find_package() would resolve libz.a
list(APPEND ZLIB_LIBRARIES z)
elseif (CLR_CMAKE_HOST_ARCH_ARMV6)
find_package(ZLIB REQUIRED)
list(APPEND ZLIB_LIBRARIES z)
elseif (CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS)
find_package(ZLIB REQUIRED)
list(APPEND ZLIB_LIBRARIES m)
else()
list(APPEND ZLIB_LIBRARIES zlib)
# 'z' is used in:
# - Platforms that set CMAKE_USE_SYSTEM_ZLIB to true, like Android.
# - When it is set to true via CLI using --cmakeargs.
# 'zlib' represents our in-tree zlib, and is used in all other platforms
# that don't meet any of the previous special requirements, like most
# regular Unix and Windows builds.
list(APPEND ZLIB_LIBRARIES $<IF:$<BOOL:CLR_CMAKE_USE_SYSTEM_ZLIB>,z,zlib>)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to delete the ANDROID special-case above since it should be handled by this condition just fine now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Done. I also added a comment.

endif ()
list(APPEND ${NativeLibsExtra} ${ZLIB_LIBRARIES})

Expand Down
Loading