15304034fSPetr Hosekinclude(CMakePushCheckState) 2*89946bdaSh-vetinariinclude(CheckCompilerFlag) 355e65ad8SPetr Hosek 455e65ad8SPetr Hosekfunction(llvm_check_compiler_linker_flag lang flag out_var) 5*89946bdaSh-vetinari # If testing a flag with check_compiler_flag, it gets added to the compile 65304034fSPetr Hosek # command only, but not to the linker command in that test. If the flag 75304034fSPetr Hosek # is vital for linking to succeed, the test would fail even if it would 85304034fSPetr Hosek # have succeeded if it was included on both commands. 95304034fSPetr Hosek # 105304034fSPetr Hosek # Therefore, try adding the flag to CMAKE_REQUIRED_FLAGS, which gets 115304034fSPetr Hosek # added to both compiling and linking commands in the tests. 125304034fSPetr Hosek 135304034fSPetr Hosek cmake_push_check_state() 145304034fSPetr Hosek set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}") 155304034fSPetr Hosek check_compiler_flag("${lang}" "" ${out_var}) 165304034fSPetr Hosek cmake_pop_check_state() 175304034fSPetr Hosekendfunction() 18