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

cmake: allow building liblphobos with system zlib #4716

Closed
wants to merge 1 commit into from
Closed
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
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ include(HandleLTOPGOBuildOptions)
#
set(LDC_DYNAMIC_COMPILE "AUTO" CACHE STRING "Support dynamic compilation (ON|OFF). Enabled by default; not supported for LLVM >= 12.")
option(LDC_DYNAMIC_COMPILE_USE_CUSTOM_PASSES "Use custom LDC passes in jit" ON)
option(LDC_PHOBOS_USE_SYSTEM_ZLIB "Use system zlib instead of bundled zlib in libphobos" OFF)
if(LDC_DYNAMIC_COMPILE STREQUAL "AUTO")
if(LDC_LLVM_VER LESS 1200)
set(LDC_DYNAMIC_COMPILE ON)
Expand All @@ -461,6 +462,10 @@ if(LDC_DYNAMIC_COMPILE)
add_definitions(-DLDC_DYNAMIC_COMPILE)
add_definitions(-DLDC_DYNAMIC_COMPILE_API_VERSION=3)
endif()
if(LDC_PHOBOS_USE_SYSTEM_ZLIB)
find_package(ZLIB 1.3 REQUIRED)
message(STATUS "Building LDC with system zlib version ${ZLIB_VERSION}")
endif()

#
# Includes, defines.
Expand Down
8 changes: 8 additions & 0 deletions runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ if("${C_SYSTEM_LIBS}" STREQUAL "AUTO")
else()
set(C_SYSTEM_LIBS_SHARED ${C_SYSTEM_LIBS})
endif()
if(LDC_PHOBOS_USE_SYSTEM_ZLIB)
list(APPEND C_SYSTEM_LIBS ZLIB::ZLIB)
list(APPEND C_SYSTEM_LIBS_SHARED ZLIB::ZLIB)
endif()

message(STATUS "-- LDC runtime configuration:")
message(STATUS "-- - Building 32/64-bit libraries (MULTILIB): ${MULTILIB}")
Expand Down Expand Up @@ -252,6 +256,10 @@ if(PHOBOS2_DIR)
${PHOBOS2_DIR}/etc/c/zlib/test/minigzip.c
)
endif()
if(LDC_PHOBOS_USE_SYSTEM_ZLIB)
# filter out zlib C parts if system zlib is used
list(FILTER PHOBOS2_C EXCLUDE REGEX ".*/etc/c/zlib/.*\\.c")
endif()

#
# Create configuration files.
Expand Down