diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
commit | e6918187568dbd01842d8d1d2c808ce16a894239 (patch) | |
tree | 64f88b554b444a49f656b6c656111a145cbbaa28 /cmake/modules/FindZstd.cmake | |
parent | Initial commit. (diff) | |
download | ceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip |
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | cmake/modules/FindZstd.cmake | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/cmake/modules/FindZstd.cmake b/cmake/modules/FindZstd.cmake new file mode 100644 index 000000000..44d2dc3d8 --- /dev/null +++ b/cmake/modules/FindZstd.cmake @@ -0,0 +1,51 @@ +# Try to find liblz4 +# +# Once done, this will define +# +# Zstd_FOUND +# Zstd_INCLUDE_DIRS +# Zstd_LIBRARIES +# Zstd_VERSION_STRING +# Zstd_VERSION_MAJOR +# Zstd_VERSION_MINOR +# Zstd_VERSION_RELEASE + +find_path(Zstd_INCLUDE_DIR + NAMES zstd.h + HINTS ${Zstd_ROOT_DIR}/include) + +if(Zstd_INCLUDE_DIR AND EXISTS "${Zstd_INCLUDE_DIR}/zstd.h") + foreach(ver "MAJOR" "MINOR" "RELEASE") + file(STRINGS "${Zstd_INCLUDE_DIR}/zstd.h" Zstd_VER_${ver}_LINE + REGEX "^#define[ \t]+ZSTD_VERSION_${ver}[ \t]+[0-9]+$") + string(REGEX REPLACE "^#define[ \t]+ZSTD_VERSION_${ver}[ \t]+([0-9]+)$" + "\\1" Zstd_VERSION_${ver} "${Zstd_VER_${ver}_LINE}") + unset(${Zstd_VER_${ver}_LINE}) + endforeach() + set(Zstd_VERSION_STRING + "${Zstd_VERSION_MAJOR}.${Zstd_VERSION_MINOR}.${Zstd_VERSION_RELEASE}") +endif() + +find_library(Zstd_LIBRARY + NAMES "${CMAKE_STATIC_LIBRARY_PREFIX}zstd.${CMAKE_STATIC_LIBRARY_SUFFIX}" zstd + HINTS ${Zstd_ROOT_DIR}/lib) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Zstd + REQUIRED_VARS Zstd_LIBRARY Zstd_INCLUDE_DIR + VERSION_VAR Zstd_VERSION_STRING) + +mark_as_advanced( + Zstd_LIBRARY + Zstd_INCLUDE_DIR) + +if(Zstd_FOUND AND NOT (TARGET Zstd::Zstd)) + set(Zstd_INCLUDE_DIRS ${Zstd_INCLUDE_DIR}) + set(Zstd_LIBRARIES ${Zstd_LIBRARY}) + add_library (Zstd::Zstd UNKNOWN IMPORTED) + set_target_properties(Zstd::Zstd PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${Zstd_INCLUDE_DIR} + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION ${Zstd_LIBRARY} + VERSION "${Zstd_VERSION_STRING}") +endif() |