[CMake] Cache check results and avoid duplicate checks

This caches the result of builtin_check_c_compiler_flag, and removes a duplicate check for C99 flag support.

llvm-svn: 269230
This commit is contained in:
Chris Bieneman 2016-05-11 20:37:43 +00:00
parent 1592d76d73
commit 1455de2171
2 changed files with 9 additions and 8 deletions

View File

@ -49,12 +49,14 @@ function(try_compile_only output)
endfunction()
function(builtin_check_c_compiler_flag flag output)
message(STATUS "Performing Test ${output}")
try_compile_only(result ${flag})
set(${output} ${result} PARENT_SCOPE)
if(${result})
message(STATUS "Performing Test ${output} - Success")
else()
message(STATUS "Performing Test ${output} - Failed")
if(NOT DEFINED ${output})
message(STATUS "Performing Test ${output}")
try_compile_only(result ${flag})
set(${output} ${result} CACHE INTERNAL "Compiler supports ${flag}")
if(${result})
message(STATUS "Performing Test ${output} - Success")
else()
message(STATUS "Performing Test ${output} - Failed")
endif()
endif()
endfunction()

View File

@ -29,7 +29,6 @@ check_cxx_compiler_flag(-std=c++11 COMPILER_RT_HAS_STD_CXX11_FLAG)
check_cxx_compiler_flag(-ftls-model=initial-exec COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC)
check_cxx_compiler_flag(-fno-lto COMPILER_RT_HAS_FNO_LTO_FLAG)
check_cxx_compiler_flag("-Werror -msse3" COMPILER_RT_HAS_MSSE3_FLAG)
check_cxx_compiler_flag(-std=c99 COMPILER_RT_HAS_STD_C99_FLAG)
check_cxx_compiler_flag(--sysroot=. COMPILER_RT_HAS_SYSROOT_FLAG)
if(NOT WIN32 AND NOT CYGWIN)