This is an automated email from the ASF dual-hosted git repository.
wgtmac pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-cpp.git
The following commit(s) were added to refs/heads/main by this push:
new 2e87038e fix(cmake): use consistent generator expressions to link
libraries (#639)
2e87038e is described below
commit 2e87038e181dd8af4fdf6630785391159894a7c6
Author: Junwang Zhao <[email protected]>
AuthorDate: Wed May 6 11:30:12 2026 +0800
fix(cmake): use consistent generator expressions to link libraries (#639)
---
example/CMakeLists.txt | 6 ++++--
src/iceberg/test/CMakeLists.txt | 8 ++++++--
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt
index f89058ed..a9bf73cf 100644
--- a/example/CMakeLists.txt
+++ b/example/CMakeLists.txt
@@ -26,5 +26,7 @@ find_package(iceberg CONFIG REQUIRED COMPONENTS bundle rest)
add_executable(demo_example demo_example.cc)
-target_link_libraries(demo_example PRIVATE iceberg::iceberg_bundle_shared
- iceberg::iceberg_rest_shared)
+target_link_libraries(demo_example
+ PRIVATE
"$<IF:$<TARGET_EXISTS:iceberg::iceberg_bundle_shared>,iceberg::iceberg_bundle_shared,iceberg::iceberg_bundle_static>"
+
"$<IF:$<TARGET_EXISTS:iceberg::iceberg_rest_shared>,iceberg::iceberg_rest_shared,iceberg::iceberg_rest_static>"
+)
diff --git a/src/iceberg/test/CMakeLists.txt b/src/iceberg/test/CMakeLists.txt
index 3355dacf..6b98951a 100644
--- a/src/iceberg/test/CMakeLists.txt
+++ b/src/iceberg/test/CMakeLists.txt
@@ -46,13 +46,17 @@ function(add_iceberg_test test_name)
target_sources(${test_name} PRIVATE ${ARG_SOURCES})
if(ARG_USE_BUNDLE)
- target_link_libraries(${test_name} PRIVATE iceberg_bundle_static
GTest::gmock_main)
+ target_link_libraries(${test_name}
+ PRIVATE
"$<IF:$<TARGET_EXISTS:iceberg_bundle_static>,iceberg_bundle_static,iceberg_bundle_shared>"
+ GTest::gmock_main)
elseif(ARG_USE_DATA)
target_link_libraries(${test_name}
PRIVATE
"$<IF:$<TARGET_EXISTS:iceberg_data_static>,iceberg_data_static,iceberg_data_shared>"
GTest::gmock_main)
else()
- target_link_libraries(${test_name} PRIVATE iceberg_static
GTest::gmock_main)
+ target_link_libraries(${test_name}
+ PRIVATE
"$<IF:$<TARGET_EXISTS:iceberg_static>,iceberg_static,iceberg_shared>"
+ GTest::gmock_main)
endif()
if(MSVC_TOOLCHAIN)