Skip to content

Commit 10833d5

Browse files
hjmallonNeroBurner
authored andcommitted
hunter: download zstd and link against CMake targets
Coauthored by: Reinhold Gschweicher <[email protected]>
1 parent 5768d3a commit 10833d5

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

CMakeLists.txt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,11 +620,27 @@ endif()
620620
option(CURL_ZSTD "Set to ON to enable building curl with zstd support." OFF)
621621
set(HAVE_ZSTD OFF)
622622
if(CURL_ZSTD)
623-
find_package(Zstd REQUIRED)
623+
hunter_add_package(zstd)
624+
if(HUNTER_ENABLED)
625+
find_package(zstd CONFIG REQUIRED)
626+
set(Zstd_FOUND "${zstd_FOUND}")
627+
set(Zstd_VERSION "${zstd_VERSION}")
628+
else()
629+
find_package(Zstd REQUIRED)
630+
endif()
624631
if(Zstd_FOUND AND NOT Zstd_VERSION VERSION_LESS "1.0.0")
625632
set(HAVE_ZSTD ON)
633+
if(TARGET zstd::libzstd_static) # prefer zstd CMake targets
634+
list(APPEND CURL_LIBS zstd::libzstd_static)
635+
message(STATUS "found zstd ${Zstd_VERSION}, linking against target zstd::libzstd_static")
636+
elseif(TARGET zstd::libzstd_shared)
637+
list(APPEND CURL_LIBS zstd::libzstd_shared)
638+
message(STATUS "found zstd ${Zstd_VERSION}, linking against target zstd::libzstd_shared")
639+
else() # no indent to keep diffs small
640+
message(STATUS "found zstd ${Zstd_VERSION}, but no specific cmake target")
626641
list(APPEND CURL_LIBS ${Zstd_LIBRARIES})
627642
include_directories(${Zstd_INCLUDE_DIRS})
643+
endif()
628644
else()
629645
message(WARNING "zstd v1.0.0 or newer is required, disabling zstd support.")
630646
endif()

0 commit comments

Comments
 (0)