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

Remove dependency on ZLIB #8023

Merged
merged 4 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
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
26 changes: 0 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -305,32 +305,6 @@ if(REALM_NEEDS_OPENSSL OR REALM_FORCE_OPENSSL)
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)" OPENSSL_VERSION_MAJOR_MINOR "${OPENSSL_VERSION}")
endif()

# Use Zlib for Sync, but allow integrators to override it
# Don't use find_library(ZLIB) on Apple platforms - it hardcodes the path per platform,
# so for an iOS build it'll use the path from the Device plaform, which is an error on Simulator.
# Just use -lz and let Xcode figure it out
# Emscripten does provide Zlib, but it doesn't work with find_package and is handled specially
if(NOT APPLE AND NOT EMSCRIPTEN AND NOT TARGET ZLIB::ZLIB)
if(WIN32 OR (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND REALM_LINUX_TOOLCHAIN))
find_package(ZLIB)
if (NOT ZLIB_FOUND)
realm_acquire_dependency(zlib ${DEP_ZLIB_VERSION} ZLIB_CMAKE_INCLUDE_FILE)
include(${ZLIB_CMAKE_INCLUDE_FILE})
endif()
elseif(ANDROID)
# On Android FindZLIB chooses the static libz over the dynamic one, but this leads to issues
# (see https://github.com/android/ndk/issues/1179)
# We want to link against the stub library instead of statically linking anyway,
# so we hack find_library to only consider shared object libraries when looking for libz
set(_CMAKE_FIND_LIBRARY_SUFFIXES_orig ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES .so)
endif()
find_package(ZLIB REQUIRED)
if(ANDROID)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_CMAKE_FIND_LIBRARY_SUFFIXES_orig})
endif()
endif()

# Store configuration in header file
configure_file(src/realm/util/config.h.in src/realm/util/config.h)

Expand Down
2 changes: 0 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,6 @@ let package = Package(
.headerSearchPath("external"),
] + cxxSettings) as [CXXSetting],
linkerSettings: [
.linkedLibrary("compression"),
.linkedLibrary("z"),
.linkedFramework("Foundation", .when(platforms: [.macOS, .iOS, .tvOS, .watchOS, .macCatalyst])),
.linkedFramework("Security", .when(platforms: [.macOS, .iOS, .tvOS, .watchOS, .macCatalyst])),
]),
Expand Down
1 change: 0 additions & 1 deletion dependencies.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
PACKAGE_NAME: realm-core
VERSION: 20.0.0
OPENSSL_VERSION: 3.3.1
ZLIB_VERSION: 1.2.13
# https://github.com/10gen/baas/commits
# 2f308db is 2024 July 10
BAAS_VERSION: 2f308db6f65333728a101d1fecbb792f9659a5ce
Expand Down
18 changes: 0 additions & 18 deletions src/realm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ set(UTIL_SOURCES
util/base64.cpp
util/basic_system_errors.cpp
util/cli_args.cpp
util/compression.cpp
util/encrypted_file_mapping.cpp
util/fifo_helper.cpp
util/file.cpp
Expand Down Expand Up @@ -224,7 +223,6 @@ set(REALM_INSTALL_HEADERS
util/buffer_stream.hpp
util/cf_ptr.hpp
util/checked_mutex.hpp
util/compression.hpp
util/encrypted_file_mapping.hpp
util/errno.hpp
util/features.h
Expand Down Expand Up @@ -397,22 +395,6 @@ if(REALM_HAVE_OPENSSL AND (UNIX OR WIN32))
target_link_libraries(Storage PUBLIC OpenSSL::Crypto)
endif()

# Use Zlib if the imported target is defined, otherise use -lz on Apple platforms
if(TARGET ZLIB::ZLIB)
target_link_libraries(Storage PUBLIC ZLIB::ZLIB)
elseif(APPLE)
target_link_options(Storage PUBLIC "-lz")
elseif(EMSCRIPTEN)
target_compile_options(Storage PUBLIC "-sUSE_ZLIB=1")
target_link_options(Storage PUBLIC "-sUSE_ZLIB=1")
else()
message(FATAL_ERROR "No zlib dependency defined")
endif()

if(APPLE)
target_link_libraries(Storage PUBLIC "-lcompression")
endif()

install(TARGETS Storage EXPORT realm
ARCHIVE DESTINATION lib
COMPONENT devel)
Expand Down
Loading
Loading