Skip to content

Commit

Permalink
[llvm][cmake] Shore up llvm_check_linker_flags.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Ericson2314 committed Jul 25, 2022
1 parent f4ac950 commit 3ebb2c0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions llvm/cmake/modules/LLVMCheckLinkerFlag.cmake
Expand Up @@ -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")
Expand All @@ -22,5 +24,6 @@ else()
message(FATAL_ERROR "\"${lang}\" is not C or CXX")
endif()
cmake_pop_check_state()
cmake_policy(POP)
endfunction()
endif()

0 comments on commit 3ebb2c0

Please sign in to comment.