From 945066a02d52119a28b2069d8b04b312e4b028c5 Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Tue, 25 Apr 2023 18:49:59 +0800 Subject: [PATCH] Try finding cityhash with `find_package` first --- CMakeLists.txt | 8 +++++++- clickhouse/CMakeLists.txt | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 44cd36d6..49a73122 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,7 +77,13 @@ PROJECT (CLICKHOUSE-CLIENT) ENDIF () IF (WITH_SYSTEM_CITYHASH) - FIND_LIBRARY(SYSTEM_CITYHASH NAMES cityhash REQUIRED) + # Try with FIND_PACKAGE first, as conan and vcpkg provide a CMake + # package for cityhash. + FIND_PACKAGE(cityhash) + IF (NOT cityhash_FOUND) + # Fall back to FIND_LIBRARY, if no CMake package is found. + FIND_LIBRARY(SYSTEM_CITYHASH NAMES cityhash REQUIRED) + ENDIF () ELSE () INCLUDE_DIRECTORIES (contrib/cityhash/cityhash) SUBDIRS (contrib/cityhash/cityhash) diff --git a/clickhouse/CMakeLists.txt b/clickhouse/CMakeLists.txt index 9680c164..561c5d8b 100644 --- a/clickhouse/CMakeLists.txt +++ b/clickhouse/CMakeLists.txt @@ -38,7 +38,7 @@ IF (WITH_OPENSSL) LIST(APPEND clickhouse-cpp-lib-src base/sslsocket.cpp) ENDIF () -IF (WITH_SYSTEM_CITYHASH) +IF (WITH_SYSTEM_CITYHASH AND NOT cityhash_FOUND) SET (CITYHASH ${SYSTEM_CITYHASH}) ELSE () SET (CITYHASH cityhash::cityhash)