Skip to content

Commit 2e87038

Browse files
authored
fix(cmake): use consistent generator expressions to link libraries (#639)
1 parent 0db527a commit 2e87038

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

example/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,7 @@ find_package(iceberg CONFIG REQUIRED COMPONENTS bundle rest)
2626

2727
add_executable(demo_example demo_example.cc)
2828

29-
target_link_libraries(demo_example PRIVATE iceberg::iceberg_bundle_shared
30-
iceberg::iceberg_rest_shared)
29+
target_link_libraries(demo_example
30+
PRIVATE "$<IF:$<TARGET_EXISTS:iceberg::iceberg_bundle_shared>,iceberg::iceberg_bundle_shared,iceberg::iceberg_bundle_static>"
31+
"$<IF:$<TARGET_EXISTS:iceberg::iceberg_rest_shared>,iceberg::iceberg_rest_shared,iceberg::iceberg_rest_static>"
32+
)

src/iceberg/test/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,17 @@ function(add_iceberg_test test_name)
4646
target_sources(${test_name} PRIVATE ${ARG_SOURCES})
4747

4848
if(ARG_USE_BUNDLE)
49-
target_link_libraries(${test_name} PRIVATE iceberg_bundle_static GTest::gmock_main)
49+
target_link_libraries(${test_name}
50+
PRIVATE "$<IF:$<TARGET_EXISTS:iceberg_bundle_static>,iceberg_bundle_static,iceberg_bundle_shared>"
51+
GTest::gmock_main)
5052
elseif(ARG_USE_DATA)
5153
target_link_libraries(${test_name}
5254
PRIVATE "$<IF:$<TARGET_EXISTS:iceberg_data_static>,iceberg_data_static,iceberg_data_shared>"
5355
GTest::gmock_main)
5456
else()
55-
target_link_libraries(${test_name} PRIVATE iceberg_static GTest::gmock_main)
57+
target_link_libraries(${test_name}
58+
PRIVATE "$<IF:$<TARGET_EXISTS:iceberg_static>,iceberg_static,iceberg_shared>"
59+
GTest::gmock_main)
5660
endif()
5761

5862
if(MSVC_TOOLCHAIN)

0 commit comments

Comments
 (0)