Skip to content

Commit 81ef817

Browse files
committed
Keep absl API available in the shared library
1 parent b8544bb commit 81ef817

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

clickhouse/CMakeLists.txt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,25 @@ SET_TARGET_PROPERTIES (clickhouse-cpp-lib
109109
LINKER_LANGUAGE CXX
110110
VERSION ${CLICKHOUSE_CPP_VERSION}
111111
)
112+
113+
# Make sure the API of absl's UInt128 is also available when using ClickHouse-cpp
114+
# as a shared library. This currently works only for Linux and Windows
115+
IF (BUILD_SHARED_LIBS AND NOT WITH_SYSTEM_ABSEIL)
116+
GET_TARGET_PROPERTY(absl_lib absl::int128 ALIASED_TARGET)
117+
SET_PROPERTY (TARGET ${absl_lib} PROPERTY POSITION_INDEPENDENT_CODE ON)
118+
TARGET_LINK_LIBRARIES (clickhouse-cpp-lib
119+
$<$<PLATFORM_ID:Darwin>:-Wl,-force_load,$<TARGET_FILE:${absl_lib}>>
120+
$<$<PLATFORM_ID:Linux>:-Wl,--whole-archive>
121+
absl::int128
122+
$<$<PLATFORM_ID:Linux>:-Wl,--no-whole-archive>
123+
)
124+
ELSE ()
125+
TARGET_LINK_LIBRARIES (clickhouse-cpp-lib
126+
absl::int128
127+
)
128+
ENDIF ()
129+
112130
TARGET_LINK_LIBRARIES (clickhouse-cpp-lib
113-
absl::int128
114131
cityhash::cityhash
115132
lz4::lz4
116133
zstd::zstd

0 commit comments

Comments
 (0)