Skip to content

Commit

Permalink
Conditionally fix name of zlib that the linker needs (#104904)
Browse files Browse the repository at this point in the history
* Conditionally fix the name of zlib that the linker needs

* Remove the android branch, add a comment to explain when z and zlib are used.

---------

Co-authored-by: Carlos Sánchez López <1175054+carlossanlop@users.noreply.github.com>
Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com>
  • Loading branch information
3 people authored and pull[bot] committed Nov 14, 2024
1 parent e8b5bd0 commit 9753685
Showing 1 changed file with 7 additions and 4 deletions.
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>)
endif ()
list(APPEND ${NativeLibsExtra} ${ZLIB_LIBRARIES})

Expand Down

0 comments on commit 9753685

Please sign in to comment.