[llvm] [CMake] Enable CMP0156 if available (PR #115046)
Evan Wilde via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 5 10:43:10 PST 2024
https://github.com/etcwilde created https://github.com/llvm/llvm-project/pull/115046
Some linkers do not require that libraries are repeated on the command line. The Apple linker emits warnings when duplicate libraries are specified, resulting in a wall of warnings.
CMP0156 deduplicates libraries on the command line when the linker doesn't require them.
This patch enables CMP0156 to quiet the warnings when using a version of CMake that recognizes it (CMake 3.29 and newer).
>From 9d92e32471d4767bd07f1dc3cb28a9da1966a775 Mon Sep 17 00:00:00 2001
From: Evan Wilde <etceterawilde at gmail.com>
Date: Tue, 5 Nov 2024 10:24:25 -0800
Subject: [PATCH] Enable CMP0156
Some linkers do not require that libraries are repeated on the command
line. The Apple linker emits warnings when duplicate libraries are
specified, resulting in a wall of warnings.
CMP0156 deduplicates libraries on the command line when the linker
doesn't require them.
This patch enables CMP0156 to quiet the warnings when using a version of
CMake that recognizes it (CMake 3.29 and newer).
---
cmake/Modules/CMakePolicy.cmake | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/cmake/Modules/CMakePolicy.cmake b/cmake/Modules/CMakePolicy.cmake
index f19dfd71657171..d561556b2830f9 100644
--- a/cmake/Modules/CMakePolicy.cmake
+++ b/cmake/Modules/CMakePolicy.cmake
@@ -30,3 +30,11 @@ endif()
if(POLICY CMP0147)
cmake_policy(SET CMP0147 NEW)
endif()
+
+# CMP0156: De-duplicate libraries on link lines based on linker capabilities.
+# New in CMake 3.29: https://cmake.org/cmake/help/latest/policy/CMP0156.html
+# Avoids the deluge of 'ld: warning: ignoring duplicate libraries' warnings when
+# building with the Apple linker.
+if(POLICY CMP0156)
+ cmake_policy(SET CMP0156 NEW)
+endif()
More information about the llvm-commits
mailing list