File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,6 +45,21 @@ option(ICEBERG_BUILD_REST "Build rest catalog client" ON)
4545option (ICEBERG_ENABLE_ASAN "Enable Address Sanitizer" OFF )
4646option (ICEBERG_ENABLE_UBSAN "Enable Undefined Behavior Sanitizer" OFF )
4747
48+ if (ICEBERG_BUILD_SHARED)
49+ set (ICEBERG_TEST_LINKAGE_DEFAULT "shared" )
50+ else ()
51+ set (ICEBERG_TEST_LINKAGE_DEFAULT "static" )
52+ endif ()
53+ set (ICEBERG_TEST_LINKAGE ${ICEBERG_TEST_LINKAGE_DEFAULT} CACHE STRING "Linkage of Iceberg libraries with unit tests executables" )
54+ if (ICEBERG_BUILD_TESTS)
55+ if (ICEBERG_TEST_LINKAGE STREQUAL "shared" AND NOT ICEBERG_BUILD_SHARED)
56+ message (FATAL_ERROR "If using ICEBERG_TEST_LINKAGE=shared, must also pass ICEBERG_BUILD_SHARED=on" )
57+ endif ()
58+ if (ICEBERG_TEST_LINKAGE STREQUAL "static" AND NOT ICEBERG_BUILD_STATIC)
59+ message (FATAL_ERROR "If using ICEBERG_TEST_LINKAGE=static, must also pass ICEBERG_BUILD_STATIC=on" )
60+ endif ()
61+ endif ()
62+
4863include (GNUInstallDirs )
4964include (FetchContent )
5065
Original file line number Diff line number Diff line change @@ -52,12 +52,20 @@ function(add_iceberg_test test_name)
5252
5353 target_sources (${test_name} PRIVATE ${ARG_SOURCES} )
5454
55- if (ARG_USE_BUNDLE)
56- target_link_libraries (${test_name} PRIVATE iceberg_bundle_static GTest::gtest_main
57- GTest::gmock )
55+ target_link_libraries (${test_name} PRIVATE GTest::gtest_main GTest::gmock )
56+
57+ if ("${ICEBERG_TEST_LINKAGE} " STREQUAL "shared" )
58+ if (ARG_USE_BUNDLE)
59+ target_link_libraries (${test_name} PRIVATE iceberg_bundle_shared )
60+ else ()
61+ target_link_libraries (${test_name} PRIVATE iceberg_shared )
62+ endif ()
5863 else ()
59- target_link_libraries (${test_name} PRIVATE iceberg_static GTest::gtest_main
60- GTest::gmock )
64+ if (ARG_USE_BUNDLE)
65+ target_link_libraries (${test_name} PRIVATE iceberg_bundle_static )
66+ else ()
67+ target_link_libraries (${test_name} PRIVATE iceberg_static )
68+ endif ()
6169 endif ()
6270
6371 add_test (NAME ${test_name} COMMAND ${test_name} )
@@ -160,8 +168,14 @@ if(ICEBERG_BUILD_BUNDLE)
160168endif ()
161169
162170if (ICEBERG_BUILD_REST)
163- add_iceberg_test (rest_catalog_test SOURCES rest_catalog_test.cc
171+ add_iceberg_test (rest_catalog_test
172+ SOURCES
173+ rest_catalog_test.cc
164174 rest_json_internal_test.cc )
165- target_link_libraries (rest_catalog_test PRIVATE iceberg_rest_static )
175+ if ("${ICEBERG_TEST_LINKAGE} " STREQUAL "shared" )
176+ target_link_libraries (rest_catalog_test PRIVATE iceberg_rest_shared )
177+ else ()
178+ target_link_libraries (rest_catalog_test PRIVATE iceberg_rest_static )
179+ endif ()
166180 target_include_directories (rest_catalog_test PRIVATE ${cpp-httplib_SOURCE_DIR} )
167181endif ()
You can’t perform that action at this time.
0 commit comments