From b99d338dbcef3f0d54fa1faeb8a24a727c0ab8ab 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, so it cannot be imported with `find_package` or used with the alias `cityhash::cityhash`. To fix that, we need the following: 1. Use `find_library` to find the `cityhash` library. 2. When `find_library` is used, conditionally link against its result. Signed-off-by: Ruoyu Zhong --- CMakeLists.txt | 2 +- clickhouse/CMakeLists.txt | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aed0d85c..44cd36d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,7 +77,7 @@ PROJECT (CLICKHOUSE-CLIENT) ENDIF () IF (WITH_SYSTEM_CITYHASH) - FIND_PACKAGE(cityhash REQUIRED) + FIND_LIBRARY(SYSTEM_CITYHASH NAMES cityhash REQUIRED) ELSE () INCLUDE_DIRECTORIES (contrib/cityhash/cityhash) SUBDIRS (contrib/cityhash/cityhash) diff --git a/clickhouse/CMakeLists.txt b/clickhouse/CMakeLists.txt index 67663ec5..9680c164 100644 --- a/clickhouse/CMakeLists.txt +++ b/clickhouse/CMakeLists.txt @@ -38,12 +38,18 @@ IF (WITH_OPENSSL) LIST(APPEND clickhouse-cpp-lib-src base/sslsocket.cpp) ENDIF () +IF (WITH_SYSTEM_CITYHASH) + SET (CITYHASH ${SYSTEM_CITYHASH}) +ELSE () + SET (CITYHASH cityhash::cityhash) +ENDIF () + ADD_LIBRARY (clickhouse-cpp-lib ${clickhouse-cpp-lib-src}) SET_TARGET_PROPERTIES (clickhouse-cpp-lib PROPERTIES LINKER_LANGUAGE CXX) TARGET_LINK_LIBRARIES (clickhouse-cpp-lib absl::int128 - cityhash::cityhash lz4::lz4 + ${CITYHASH} ) TARGET_INCLUDE_DIRECTORIES (clickhouse-cpp-lib PUBLIC ${PROJECT_SOURCE_DIR}