1# CMake policy settings shared between LLVM projects 2 3# CMP0116: Ninja generators transform `DEPFILE`s from `add_custom_command()` 4# New in CMake 3.20. https://cmake.org/cmake/help/latest/policy/CMP0116.html 5if(POLICY CMP0116) 6 cmake_policy(SET CMP0116 OLD) 7endif() 8 9# MSVC debug information format flags are selected via 10# CMAKE_MSVC_DEBUG_INFORMATION_FORMAT, instead of 11# embedding flags in e.g. CMAKE_CXX_FLAGS_RELEASE. 12# New in CMake 3.25. 13# 14# Supports debug info with SCCache 15# (https://github.com/mozilla/sccache?tab=readme-ov-file#usage) 16# avoiding “fatal error C1041: cannot open program database; if 17# multiple CL.EXE write to the same .PDB file, please use /FS" 18if(POLICY CMP0141) 19 cmake_policy(SET CMP0141 NEW) 20endif() 21 22# CMP0144: find_package() uses uppercase <PackageName>_ROOT variables. 23# New in CMake 3.27: https://cmake.org/cmake/help/latest/policy/CMP0144.html 24if(POLICY CMP0144) 25 cmake_policy(SET CMP0144 NEW) 26endif() 27 28# CMP0147: Visual Studio Generators build custom commands in parallel. 29# New in CMake 3.27: https://cmake.org/cmake/help/latest/policy/CMP0147.html 30if(POLICY CMP0147) 31 cmake_policy(SET CMP0147 NEW) 32endif() 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. 38if(POLICY CMP0156) 39 cmake_policy(SET CMP0156 NEW) 40 41 # CMP0179: De-duplication of static libraries on link lines keeps first occurrence. 42 # Dependent on CMP0156=NEW. Unifies the behaviour across platforms. 43 # Works around a LLD bug ELF backend bug (#116669) and required for CMP0156 44 # to have an effect for affected versions. Also fixes building with CMake 3.31.0, 45 # which lacked the workaround of ignoring CMP0156 unless this is enabled. 46 if(POLICY CMP0179) 47 cmake_policy(SET CMP0179 NEW) 48 endif() 49endif() 50