Skip to content

Commit cb90d5b

Browse files
authored
[CMake] Enable CMP0156 if available (llvm#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).
1 parent aae5a38 commit cb90d5b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cmake/Modules/CMakePolicy.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,11 @@ endif()
3030
if(POLICY CMP0147)
3131
cmake_policy(SET CMP0147 NEW)
3232
endif()
33+
34+
# CMP0156: De-duplicate libraries on link lines based on linker capabilities.
35+
# New in CMake 3.29: https://cmake.org/cmake/help/latest/policy/CMP0156.html
36+
# Avoids the deluge of 'ld: warning: ignoring duplicate libraries' warnings when
37+
# building with the Apple linker.
38+
if(POLICY CMP0156)
39+
cmake_policy(SET CMP0156 NEW)
40+
endif()

0 commit comments

Comments
 (0)