Skip to content

Commit f5135f8

Browse files
committed
cmake: fix handling of transitive zstd dependency
- Remove ZIG_ENABLE_ZSTD in favour of allowing ZIG_STATIC_ZSTD to be toggled off explicitly when ZIG_STATIC is on - Remove ZIG_ENABLE_LIBCPP (now unused)
1 parent 88e4422 commit f5135f8

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

CMakeLists.txt

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,9 @@ endif()
8989

9090
set(ZIG_STATIC off CACHE BOOL "Attempt to build a static zig executable (not compatible with glibc)")
9191
set(ZIG_SHARED_LLVM off CACHE BOOL "Prefer linking against shared LLVM libraries")
92-
set(ZIG_STATIC_LLVM off CACHE BOOL "Prefer linking against static LLVM libraries")
93-
set(ZIG_STATIC_ZLIB off CACHE BOOL "Prefer linking against static zlib")
94-
set(ZIG_ENABLE_ZSTD on CACHE BOOL "Enable linking zstd")
95-
set(ZIG_ENABLE_LIBCPP on CACHE BOOL "Enable linking libcpp")
96-
set(ZIG_STATIC_ZSTD off CACHE BOOL "Prefer linking against static zstd")
92+
set(ZIG_STATIC_LLVM ${ZIG_STATIC} CACHE BOOL "Prefer linking against static LLVM libraries")
93+
set(ZIG_STATIC_ZLIB ${ZIG_STATIC} CACHE BOOL "Prefer linking against static zlib")
94+
set(ZIG_STATIC_ZSTD ${ZIG_STATIC} CACHE BOOL "Prefer linking against static zstd")
9795
set(ZIG_USE_CCACHE off CACHE BOOL "Use ccache")
9896

9997
if(ZIG_USE_CCACHE)
@@ -105,12 +103,6 @@ if(ZIG_USE_CCACHE)
105103
endif()
106104
endif()
107105

108-
if(ZIG_STATIC)
109-
set(ZIG_STATIC_LLVM ON)
110-
set(ZIG_STATIC_ZLIB ON)
111-
set(ZIG_STATIC_ZSTD ON)
112-
endif()
113-
114106
if (ZIG_SHARED_LLVM AND ZIG_STATIC_LLVM)
115107
message(SEND_ERROR "-DZIG_SHARED_LLVM and -DZIG_STATIC_LLVM cannot both be enabled simultaneously")
116108
endif()
@@ -150,8 +142,13 @@ if(ZIG_STATIC_ZLIB)
150142
list(APPEND LLVM_LIBRARIES "${ZLIB}")
151143
endif()
152144

153-
if(ZIG_STATIC_ZSTD AND ZIG_ENABLE_ZSTD)
154-
list(REMOVE_ITEM LLVM_SYSTEM_LIBRARIES "-lzstd")
145+
if(ZIG_STATIC_ZSTD)
146+
if (MSVC)
147+
list(REMOVE_ITEM LLVM_SYSTEM_LIBRARIES "zstd.lib")
148+
else()
149+
list(REMOVE_ITEM LLVM_SYSTEM_LIBRARIES "-lzstd")
150+
endif()
151+
155152
find_library(ZSTD NAMES libzstd.a libzstdstatic.a zstd NAMES_PER_DIR)
156153
list(APPEND LLVM_LIBRARIES "${ZSTD}")
157154
endif()

0 commit comments

Comments
 (0)