From aa5e05d6ff15deb08c39891b08747cdb2d151e79 Mon Sep 17 00:00:00 2001 From: Matt Peddie Date: Tue, 29 Aug 2023 11:18:51 +1000 Subject: [PATCH] Add zstd finder file --- Findzstd.cmake | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Findzstd.cmake diff --git a/Findzstd.cmake b/Findzstd.cmake new file mode 100644 index 0000000..89f7aab --- /dev/null +++ b/Findzstd.cmake @@ -0,0 +1,41 @@ +if (TARGET zstd::zstd) + return() +endif() + +include(FindPackageHandleStandardArgs) + +if (APPLE) + file(GLOB ZSTD_DIRS + /usr/local/Cellar/zstd/* + /opt/homebrew/Cellar/zstd/* + ) +endif() + +find_path(zstd_INCLUDE_DIR + NAMES zstd.h + HINTS ${ZSTD_DIRS} + PATH_SUFFIXES include +) + +find_library(zstd_LIBRARY + NAMES zstd + HINTS ${ZSTD_DIRS} + PATH_SUFFIXES lib +) + +find_package_handle_standard_args(zstd REQUIRED_VARS + zstd_LIBRARY + zstd_INCLUDE_DIR +) + +if (zstd_FOUND) + mark_as_advanced(zstd_LIBRARY) + mark_as_advanced(zstd_INCLUDE_DIR) + + add_library(zstd::zstd UNKNOWN IMPORTED) + set_target_properties(zstd::zstd + PROPERTIES + IMPORTED_LOCATION ${zstd_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES ${zstd_INCLUDE_DIR} + ) +endif ()