Skip to content

Commit a7a52fe

Browse files
committed
cmake - support zstd config packages on Windows
1 parent ef6fbe7 commit a7a52fe

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

thirdparty.inc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,19 @@ if (WITH_ZSTD)
215215
set(ZSTD_LIB_RELEASE $ENV{ZSTD_LIB_RELEASE})
216216
endif()
217217

218+
if(ZSTD_INCLUDE AND EXISTS "${ZSTD_INCLUDE}")
219+
set(ZSTD_LIBS debug ${ZSTD_LIB_DEBUG} optimized ${ZSTD_LIB_RELEASE})
220+
else()
221+
# No explicit paths provided - try to find config package.
222+
find_package(zstd CONFIG REQUIRED)
223+
message(STATUS "zstd: found config at '${zstd_DIR}'.")
224+
set(ZSTD_LIBS zstd::libzstd_static)
225+
# Extract include dirs, because some targets (testutillib) use zstd headers without linking to zstd.
226+
get_target_property(ZSTD_INCLUDE zstd::libzstd_static INTERFACE_INCLUDE_DIRECTORIES)
227+
endif()
228+
218229
# ZSTD_STATIC_LINKING_ONLY only allows us to create an allocation functions override
219230
# When jemalloc is in use
220-
set(ZSTD_LIBS debug ${ZSTD_LIB_DEBUG} optimized ${ZSTD_LIB_RELEASE})
221-
222231
add_definitions(-DZSTD -DZSTD_STATIC_LINKING_ONLY)
223232
include_directories(${ZSTD_INCLUDE})
224233
set (THIRDPARTY_LIBS ${THIRDPARTY_LIBS} ${ZSTD_LIBS})

0 commit comments

Comments
 (0)