[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / llvm / cmake / modules / LLVMCheckLinkerFlag.cmake
blobe09bbc66f2d26e14a061b58e553bfa7b65310d5c
1 include(CheckLinkerFlag OPTIONAL)
3 if (COMMAND check_linker_flag)
4   macro(llvm_check_linker_flag)
5     check_linker_flag(${ARGN})
6   endmacro()
7 else()
8   # Until the minimum CMAKE version is 3.18
10   include(CheckCXXCompilerFlag)
12   # cmake builtin compatible, except we assume lang is C or CXX
13   function(llvm_check_linker_flag lang flag out_var)
14     cmake_policy(PUSH)
15     cmake_policy(SET CMP0056 NEW)
16     set(_CMAKE_EXE_LINKER_FLAGS_SAVE ${CMAKE_EXE_LINKER_FLAGS})
17     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flag}")
18     if("${lang}" STREQUAL "C")
19       check_c_compiler_flag("" ${out_var})
20     elseif("${lang}" STREQUAL "CXX")
21       check_cxx_compiler_flag("" ${out_var})
22     else()
23       message(FATAL_ERROR "\"${lang}\" is not C or CXX")
24     endif()
25     set(CMAKE_EXE_LINKER_FLAGS ${_CMAKE_EXE_LINKER_FLAGS_SAVE})
26     cmake_policy(POP)
27   endfunction()
28 endif()