1 include(CheckLinkerFlag OPTIONAL)
3 if (COMMAND check_linker_flag)
4 macro(llvm_check_linker_flag)
5 check_linker_flag(${ARGN})
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)
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})
23 message(FATAL_ERROR "\"${lang}\" is not C or CXX")
25 set(CMAKE_EXE_LINKER_FLAGS ${_CMAKE_EXE_LINKER_FLAGS_SAVE})