From 5ab57c3d29c105c4d193ad740f8c880ccdb0d146 Mon Sep 17 00:00:00 2001 From: Twice Date: Thu, 24 Aug 2023 10:12:20 +0800 Subject: [PATCH] Introduce dependency xxhash for bloomfilter (#1694) --- CMakeLists.txt | 2 ++ cmake/utils.cmake | 1 + cmake/xxhash.cmake | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 cmake/xxhash.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 07d3c14bb19..0a2adc4000b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,6 +131,7 @@ include(cmake/rocksdb.cmake) include(cmake/libevent.cmake) include(cmake/fmt.cmake) include(cmake/jsoncons.cmake) +include(cmake/xxhash.cmake) if (ENABLE_LUAJIT) include(cmake/luajit.cmake) @@ -160,6 +161,7 @@ list(APPEND EXTERNAL_LIBS tbb) list(APPEND EXTERNAL_LIBS jsoncons) list(APPEND EXTERNAL_LIBS Threads::Threads) list(APPEND EXTERNAL_LIBS ${Backtrace_LIBRARY}) +list(APPEND EXTERNAL_LIBS xxhash) # Add git sha to version.h find_package(Git REQUIRED) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index 40773e01349..c1a8594b89e 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -27,6 +27,7 @@ endmacro() function(FetchContent_MakeAvailableWithArgs dep) if(NOT ${dep}_POPULATED) + message("Fetching ${dep}...") FetchContent_Populate(${dep}) foreach(arg IN LISTS ARGN) diff --git a/cmake/xxhash.cmake b/cmake/xxhash.cmake new file mode 100644 index 00000000000..edcdfe18c14 --- /dev/null +++ b/cmake/xxhash.cmake @@ -0,0 +1,35 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +include_guard() + +include(cmake/utils.cmake) + +FetchContent_DeclareGitHubWithMirror(xxhash + Cyan4973/xxHash v0.8.2 + MD5=4b793d916f9b8e4ceb984a00e356bdb2 +) + +FetchContent_GetProperties(xxhash) +if(NOT xxhash_POPULATED) + FetchContent_Populate(xxhash) + + set(BUILD_SHARED_LIBS OFF) + set(XXHASH_BUILD_XXHSUM OFF) + + add_subdirectory(${xxhash_SOURCE_DIR}/cmake_unofficial ${xxhash_BUILD_DIR} EXCLUDE_FROM_ALL) +endif()