File 0005-Add-CMake-module-to-find-xxhash.patch of Package kdrive
From 0386f8f2a12d9ed2412428a828b850ed3cb5b921 Mon Sep 17 00:00:00 2001
From: Christophe Marin <christophe@krop.fr>
Date: Wed, 23 Apr 2025 17:27:00 +0200
Subject: [PATCH 05/10] Add CMake module to find xxhash
---
cmake/modules/FindxxHash.cmake | 74 ++++++++++++++++++++++++++++++
src/libcommonserver/CMakeLists.txt | 34 +++++++-------
2 files changed, 91 insertions(+), 17 deletions(-)
create mode 100644 cmake/modules/FindxxHash.cmake
diff --git a/cmake/modules/FindxxHash.cmake b/cmake/modules/FindxxHash.cmake
new file mode 100644
index 0000000..5604cb5
--- /dev/null
+++ b/cmake/modules/FindxxHash.cmake
@@ -0,0 +1,74 @@
+# SPDX-FileCopyrightText: 2025 Christophe Marin <christophe@krop.fr>
+#
+# SPDX-License-Identifier: BSD-2-Clause
+
+#[=======================================================================[.rst:
+FindxxHash
+-------------
+
+Try to find xxhash library.
+
+The following variables will be defined:
+
+``xxHash_FOUND``
+ True if xxhash is available
+``xxHash_VERSION``
+ xxhash version
+``xxHash_LIBRARIES``
+ xxhash libraries. This variable can be used with target_link_libraries()
+``xxHash_INCLUDE_DIRS``
+ Include directories of xxhash. This variable can be used with target_include_directories()
+
+If ``xxHash_FOUND`` is TRUE, the following imported target will be defined:
+
+``xxHash::xxhash``
+ The xxhash library
+
+Using the imported targets is recommended.
+
+#]=======================================================================]
+
+find_package(PkgConfig QUIET)
+pkg_check_modules(PC_xxHash QUIET IMPORTED_TARGET libxxhash)
+
+find_library(xxHash_LIBRARIES
+ NAMES xxhash
+ HINTS ${PC_xxHash_LIBRARY_DIRS}
+)
+
+find_path(xxHash_INCLUDE_DIRS
+ NAMES xxhash.h
+ HINTS ${PC_xxHash_INCLUDE_DIRS}
+)
+
+set(xxHash_VERSION ${PC_xxHash_VERSION})
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(xxHash
+ FOUND_VAR
+ xxHash_FOUND
+ REQUIRED_VARS
+ xxHash_LIBRARIES
+ xxHash_INCLUDE_DIRS
+ VERSION_VAR
+ xxHash_VERSION
+)
+
+if(xxHash_FOUND AND NOT TARGET xxHash::xxhash)
+ add_library(xxHash::xxhash UNKNOWN IMPORTED)
+ set_target_properties(xxHash::xxhash PROPERTIES
+ IMPORTED_LOCATION "${xxHash_LIBRARIES}"
+ INTERFACE_COMPILE_OPTIONS "${PC_xxHash_CFLAGS}"
+ INTERFACE_INCLUDE_DIRECTORIES "${xxHash_INCLUDE_DIRS}")
+endif()
+
+include(FeatureSummary)
+set_package_properties(xxhash PROPERTIES
+ DESCRIPTION "Extremely fast hash algorithm"
+ URL "https://xxhash.com/"
+)
+
+# Compatibility variable
+set(XXHASH_SHARED_LIBRARY "${xxHash_LIBRARIES}")
+
+mark_as_advanced(xxHash_LIBRARIES xxHash_INCLUDE_DIRS xxHash_VERSION)
diff --git a/src/libcommonserver/CMakeLists.txt b/src/libcommonserver/CMakeLists.txt
index 148629f..26ee0e2 100644
--- a/src/libcommonserver/CMakeLists.txt
+++ b/src/libcommonserver/CMakeLists.txt
@@ -169,22 +169,22 @@ else()
else()
target_link_libraries(${libcommonserver_NAME}
utf8proc)
+ include(ConanGetLibDirs)
+ get_library_dirs("OpenSSL" "openssl")
+ get_library_dirs("xxHash" "xxhash")
+ install(FILES
+ # xxHash
+ "${_xxHash_LIB_DIRS}/libxxhash.so"
+ "${_xxHash_LIB_DIRS}/libxxhash.so.0"
+ "${_xxHash_LIB_DIRS}/libxxhash.so.0.8.2"
+
+ # OpenSSL
+ "${_OpenSSL_LIB_DIRS}/libcrypto.so"
+ "${_OpenSSL_LIB_DIRS}/libcrypto.so.3"
+ "${_OpenSSL_LIB_DIRS}/libssl.so"
+ "${_OpenSSL_LIB_DIRS}/libssl.so.3"
+ DESTINATION "${CONAN_DEP_DIR}"
+ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
+ )
endif()
- include(ConanGetLibDirs)
- get_library_dirs("OpenSSL" "openssl")
- get_library_dirs("xxHash" "xxhash")
- install(FILES
- # xxHash
- "${_xxHash_LIB_DIRS}/libxxhash.so"
- "${_xxHash_LIB_DIRS}/libxxhash.so.0"
- "${_xxHash_LIB_DIRS}/libxxhash.so.0.8.2"
-
- # OpenSSL
- "${_OpenSSL_LIB_DIRS}/libcrypto.so"
- "${_OpenSSL_LIB_DIRS}/libcrypto.so.3"
- "${_OpenSSL_LIB_DIRS}/libssl.so"
- "${_OpenSSL_LIB_DIRS}/libssl.so.3"
- DESTINATION "${CONAN_DEP_DIR}"
- PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
- )
endif()
--
2.50.0