[llvm] 3ebb2c0 - [llvm][cmake] Shore up `llvm_check_linker_flags`.

John Ericson via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 25 09:02:29 PDT 2022


Author: John Ericson
Date: 2022-07-25T16:02:25Z
New Revision: 3ebb2c0427aaf636d5c141c170ee95601ced9e6a

URL: https://github.com/llvm/llvm-project/commit/3ebb2c0427aaf636d5c141c170ee95601ced9e6a
DIFF: https://github.com/llvm/llvm-project/commit/3ebb2c0427aaf636d5c141c170ee95601ced9e6a.diff

LOG: [llvm][cmake] Shore up `llvm_check_linker_flags`.

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?

Reviewed By: sebastian-ne

Differential Revision: https://reviews.llvm.org/D118546

Added: 
    

Modified: 
    llvm/cmake/modules/LLVMCheckLinkerFlag.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/modules/LLVMCheckLinkerFlag.cmake b/llvm/cmake/modules/LLVMCheckLinkerFlag.cmake
index 79c4e2cb4c2cd..cea6a7f42c841 100644
--- a/llvm/cmake/modules/LLVMCheckLinkerFlag.cmake
+++ b/llvm/cmake/modules/LLVMCheckLinkerFlag.cmake
@@ -12,6 +12,8 @@ else()
 
   # 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 @@ else()
       message(FATAL_ERROR "\"${lang}\" is not C or CXX")
     endif()
     cmake_pop_check_state()
+    cmake_policy(POP)
   endfunction()
 endif()


        


More information about the llvm-commits mailing list