diff --git a/src/iceberg/test/CMakeLists.txt b/src/iceberg/test/CMakeLists.txt index 058a9dd3c..56aca917d 100644 --- a/src/iceberg/test/CMakeLists.txt +++ b/src/iceberg/test/CMakeLists.txt @@ -371,6 +371,16 @@ if(ICEBERG_BUILD_HIVE) endif() if(ICEBERG_CXX20_COMPAT) + # De-duplicate libraries only when the linker supports it, without changing + # policies for other targets or requiring a newer CMake version. + cmake_policy(PUSH) + if(POLICY CMP0156) + cmake_policy(SET CMP0156 NEW) + endif() + if(POLICY CMP0179) + cmake_policy(SET CMP0179 NEW) + endif() + # Compile the public headers as a C++20 consumer. The list lives in # iceberg/cpp20_compatibility_internal.h, generated by # ci/scripts/generate_public_headers.py; headers of optional components are enabled @@ -422,4 +432,5 @@ if(ICEBERG_CXX20_COMPAT) target_compile_options(cpp20_compatibility_test PRIVATE /bigobj /Zc:preprocessor) endif() add_test(NAME cpp20_compatibility_test COMMAND cpp20_compatibility_test) + cmake_policy(POP) endif()