llvm-project/cmake/Modules/CheckLinkerFlag.cmake
Petr Hosek 10e5c513b5 Revert "[cmake] Duplicate {llvm,compiler_rt}_check_linker_flag for runtime libs and llvm"
This reverts commit 4af11272f57a4a6fed2932e9e0857b2c1a707c51.
2022-01-21 09:53:14 -08:00

18 lines
688 B
CMake

include(CMakePushCheckState)
include(CheckCCompilerFlag)
function(llvm_check_linker_flag flag dest)
# If testing a flag with check_c_compiler_flag, it gets added to the compile
# command only, but not to the linker command in that test. If the flag
# is vital for linking to succeed, the test would fail even if it would
# have succeeded if it was included on both commands.
#
# Therefore, try adding the flag to CMAKE_REQUIRED_FLAGS, which gets
# added to both compiling and linking commands in the tests.
cmake_push_check_state()
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}")
check_c_compiler_flag("" ${dest})
cmake_pop_check_state()
endfunction()