Skip to content

Commit b99d338

Browse files
committed
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 <[email protected]>
1 parent 5a140ad commit b99d338

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ PROJECT (CLICKHOUSE-CLIENT)
7777
ENDIF ()
7878

7979
IF (WITH_SYSTEM_CITYHASH)
80-
FIND_PACKAGE(cityhash REQUIRED)
80+
FIND_LIBRARY(SYSTEM_CITYHASH NAMES cityhash REQUIRED)
8181
ELSE ()
8282
INCLUDE_DIRECTORIES (contrib/cityhash/cityhash)
8383
SUBDIRS (contrib/cityhash/cityhash)

clickhouse/CMakeLists.txt

+7-1
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,18 @@ IF (WITH_OPENSSL)
3838
LIST(APPEND clickhouse-cpp-lib-src base/sslsocket.cpp)
3939
ENDIF ()
4040

41+
IF (WITH_SYSTEM_CITYHASH)
42+
SET (CITYHASH ${SYSTEM_CITYHASH})
43+
ELSE ()
44+
SET (CITYHASH cityhash::cityhash)
45+
ENDIF ()
46+
4147
ADD_LIBRARY (clickhouse-cpp-lib ${clickhouse-cpp-lib-src})
4248
SET_TARGET_PROPERTIES (clickhouse-cpp-lib PROPERTIES LINKER_LANGUAGE CXX)
4349
TARGET_LINK_LIBRARIES (clickhouse-cpp-lib
4450
absl::int128
45-
cityhash::cityhash
4651
lz4::lz4
52+
${CITYHASH}
4753
)
4854
TARGET_INCLUDE_DIRECTORIES (clickhouse-cpp-lib
4955
PUBLIC ${PROJECT_SOURCE_DIR}

0 commit comments

Comments
 (0)