Skip to content

Commit

Permalink
Fix system cityhash setup
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
ZhongRuoyu committed Apr 21, 2023
1 parent 5a140ad commit b99d338
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion clickhouse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit b99d338

Please sign in to comment.