From cf70f77fa1c4e3b6974da06cf502d6236ac6a06e Mon Sep 17 00:00:00 2001 From: Gang Wu Date: Wed, 14 Oct 2026 13:50:05 +0800 Subject: [PATCH] build: avoid duplicate libraries in the C++20 compatibility test --- src/iceberg/test/CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) 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()