From 81ef817d2597eb8a0dcf4adb3f30cb4f72d2d660 Mon Sep 17 00:00:00 2001 From: Andrew Slabko Date: Tue, 16 Dec 2025 19:14:59 +0100 Subject: [PATCH] Keep absl API available in the shared library --- clickhouse/CMakeLists.txt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/clickhouse/CMakeLists.txt b/clickhouse/CMakeLists.txt index 7669420a..6fd2a156 100644 --- a/clickhouse/CMakeLists.txt +++ b/clickhouse/CMakeLists.txt @@ -109,8 +109,25 @@ SET_TARGET_PROPERTIES (clickhouse-cpp-lib LINKER_LANGUAGE CXX VERSION ${CLICKHOUSE_CPP_VERSION} ) + +# Make sure the API of absl's UInt128 is also available when using ClickHouse-cpp +# as a shared library. This currently works only for Linux and Windows +IF (BUILD_SHARED_LIBS AND NOT WITH_SYSTEM_ABSEIL) + GET_TARGET_PROPERTY(absl_lib absl::int128 ALIASED_TARGET) + SET_PROPERTY (TARGET ${absl_lib} PROPERTY POSITION_INDEPENDENT_CODE ON) + TARGET_LINK_LIBRARIES (clickhouse-cpp-lib + $<$:-Wl,-force_load,$> + $<$:-Wl,--whole-archive> + absl::int128 + $<$:-Wl,--no-whole-archive> + ) +ELSE () + TARGET_LINK_LIBRARIES (clickhouse-cpp-lib + absl::int128 + ) +ENDIF () + TARGET_LINK_LIBRARIES (clickhouse-cpp-lib - absl::int128 cityhash::cityhash lz4::lz4 zstd::zstd