[PATCH] D134990: [CMake] Provide Findzstd module
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 5 01:43:55 PDT 2022
phosek updated this revision to Diff 465320.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134990/new/
https://reviews.llvm.org/D134990
Files:
llvm/cmake/modules/Findzstd.cmake
Index: llvm/cmake/modules/Findzstd.cmake
===================================================================
--- /dev/null
+++ llvm/cmake/modules/Findzstd.cmake
@@ -0,0 +1,49 @@
+# Try to find the zstd library
+#
+# If successful, the following variables will be defined:
+# zstd_INCLUDE_DIR
+# zstd_LIBRARY
+# zstd_FOUND
+#
+# Additionally, one of the following import targets will be defined:
+# zstd::libzstd_shared
+# zstd::libzstd_static
+
+if(MSVC)
+ set(zstd_SHARED_LIBRARY_SUFFIX "\\${CMAKE_LINK_LIBRARY_SUFFIX}$")
+ set(zstd_STATIC_LIBRARY_SUFFIX "_static\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")
+else()
+ set(zstd_SHARED_LIBRARY_SUFFIX "\\${CMAKE_SHARED_LIBRARY_SUFFIX}$")
+ set(zstd_STATIC_LIBRARY_SUFFIX "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")
+endif()
+
+find_path(zstd_INCLUDE_DIR NAMES zstd.h)
+find_library(zstd_LIBRARY NAMES zstd zstd_static)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(
+ zstd DEFAULT_MSG
+ zstd_LIBRARY zstd_INCLUDE_DIR
+)
+
+if(zstd_FOUND)
+ if(zstd_LIBRARY MATCHES "${zstd_SHARED_LIBRARY_SUFFIX}$" AND
+ NOT TARGET zstd::libzstd_shared)
+ add_library(zstd::libzstd_shared SHARED IMPORTED)
+ set_target_properties(zstd::libzstd_shared PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${zstd_INCLUDE_DIR}"
+ IMPORTED_LOCATION "${zstd_LIBRARY}")
+ endif()
+ if(zstd_LIBRARY MATCHES "${zstd_STATIC_LIBRARY_SUFFIX}$" AND
+ NOT TARGET zstd::libzstd_static)
+ add_library(zstd::libzstd_static STATIC IMPORTED)
+ set_target_properties(zstd::libzstd_static PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${zstd_INCLUDE_DIR}"
+ IMPORTED_LOCATION "${zstd_LIBRARY}")
+ endif()
+endif()
+
+unset(zstd_SHARED_LIBRARY_SUFFIX)
+unset(zstd_STATIC_LIBRARY_SUFFIX)
+
+mark_as_advanced(zstd_INCLUDE_DIR zstd_LIBRARY)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134990.465320.patch
Type: text/x-patch
Size: 1818 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221005/a45818d3/attachment.bin>
More information about the llvm-commits
mailing list