[PATCH] D118546: [llvm][cmake] Shore up `llvm_check_linker_flags`.

John Ericson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 29 16:08:19 PST 2022


Ericson2314 created this revision.
Ericson2314 added reviewers: phosek, beanz, compnerd.
Herald added a subscriber: mgorny.
Ericson2314 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Ensure `CMAKE_EXE_LINKER_FLAGS` effects the underlying `try_compile` by setting
this policy to use the new, non-deprecated behavior, without effecting the
caller.

Normally this shouldn't be necessary, as CMake uses
`cmake_minimum_required(VERSION 3.13.4)` consistently, but I suppose
this could rear its head in a downstream project?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118546

Files:
  llvm/cmake/modules/LLVMCheckLinkerFlag.cmake


Index: llvm/cmake/modules/LLVMCheckLinkerFlag.cmake
===================================================================
--- llvm/cmake/modules/LLVMCheckLinkerFlag.cmake
+++ llvm/cmake/modules/LLVMCheckLinkerFlag.cmake
@@ -12,6 +12,8 @@
 
   # cmake builtin compatible, except we assume lang is C or CXX
   function(llvm_check_linker_flag lang flag out_var)
+    cmake_policy(PUSH)
+    cmake_policy(SET CMP0056 NEW)
     cmake_push_check_state()
     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flag}")
     if("${lang}" STREQUAL "C")
@@ -22,5 +24,6 @@
       message(FATAL_ERROR "\"${lang}\" is not C or CXX")
     endif()
     cmake_pop_check_state()
+    cmake_policy(POP)
   endfunction()
 endif()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118546.404312.patch
Type: text/x-patch
Size: 714 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220130/f02c0bdc/attachment.bin>


More information about the llvm-commits mailing list