From bb8545991d900a842808243255afb6317a67405f Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Sat, 22 Apr 2023 02:15:39 +0800 Subject: [PATCH] Fix system cityhash setup cityhash does not provide any CMake packages. Add a `Findcityhash.cmake` script to help find cityhash. Signed-off-by: Ruoyu Zhong --- cmake/Findcityhash.cmake | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 cmake/Findcityhash.cmake diff --git a/cmake/Findcityhash.cmake b/cmake/Findcityhash.cmake new file mode 100644 index 00000000..5f71dcc4 --- /dev/null +++ b/cmake/Findcityhash.cmake @@ -0,0 +1,26 @@ +find_path(cityhash_INCLUDE_DIR + NAMES city.h + DOC "cityhash include directory") +mark_as_advanced(cityhash_INCLUDE_DIR) +find_library(cityhash_LIBRARY + NAMES cityhash libcityhash + DOC "cityhash library") +mark_as_advanced(cityhash_LIBRARY) + +# Unlike lz4, cityhash's version information does not seem to be available. + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(cityhash + REQUIRED_VARS cityhash_LIBRARY cityhash_INCLUDE_DIR) + +if (cityhash_FOUND) + set(cityhash_INCLUDE_DIRS "${cityhash_INCLUDE_DIR}") + set(cityhash_LIBRARIES "${cityhash_LIBRARY}") + + if (NOT TARGET cityhash::cityhash) + add_library(cityhash::cityhash UNKNOWN IMPORTED) + set_target_properties(cityhash::cityhash PROPERTIES + IMPORTED_LOCATION "${cityhash_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${cityhash_INCLUDE_DIR}") + endif () +endif ()