cmake: LLVM needs to link against zlib

For more details on why this dependency is needed, see
https://github.com/ziglang/zig-bootstrap/issues/57
This commit is contained in:
Andrew Kelley 2021-05-28 20:51:18 -07:00
parent c12704a339
commit f8bc5294f2

View File

@ -67,6 +67,7 @@ message("Configuring zig version ${ZIG_VERSION}")
set(ZIG_STATIC off CACHE BOOL "Attempt to build a static zig executable (not compatible with glibc)")
set(ZIG_STATIC_LLVM off CACHE BOOL "Prefer linking against static LLVM libraries")
set(ZIG_STATIC_ZLIB off CACHE BOOL "Prefer linking against static zlib")
set(ZIG_PREFER_CLANG_CPP_DYLIB off CACHE BOOL "Try to link against -lclang-cpp")
set(ZIG_USE_CCACHE off CACHE BOOL "Use ccache if available")
@ -75,7 +76,8 @@ if(CCACHE_PROGRAM AND ZIG_USE_CCACHE)
endif()
if(ZIG_STATIC)
set(ZIG_STATIC_LLVM "on")
set(ZIG_STATIC_LLVM ON)
set(ZIG_STATIC_ZLIB ON)
endif()
string(REGEX REPLACE "\\\\" "\\\\\\\\" ZIG_LIBC_LIB_DIR_ESCAPED "${ZIG_LIBC_LIB_DIR}")
@ -101,11 +103,13 @@ find_package(llvm)
find_package(clang)
find_package(lld)
if(APPLE AND ZIG_STATIC)
if(ZIG_STATIC_ZLIB)
list(REMOVE_ITEM LLVM_LIBRARIES "-lz")
find_library(ZLIB NAMES libz.a z zlib libz)
find_library(ZLIB NAMES libz.a libzlibstatic.a z zlib libz)
list(APPEND LLVM_LIBRARIES "${ZLIB}")
endif()
if(APPLE AND ZIG_STATIC)
list(REMOVE_ITEM LLVM_LIBRARIES "-lcurses")
find_library(CURSES NAMES libcurses.a curses libcurses libncurses.a ncurses libncurses)
list(APPEND LLVM_LIBRARIES "${CURSES}")