diff options
author | Chris Bieneman <beanz@apple.com> | 2016-08-01 20:18:18 +0000 |
---|---|---|
committer | Chris Bieneman <beanz@apple.com> | 2016-08-01 20:18:18 +0000 |
commit | 4783923fa8ac34403ce9433fbb09238df2c2f7f6 (patch) | |
tree | b93e71cc92fed45808e8d817ae5cee1c9c74ec89 /cmake/Modules/BuiltinTests.cmake | |
parent | 8d02463794605d3980654f84d4b1577db2e9d040 (diff) |
[CMake] Don't trust compiler error code, also check for errors
Summary: rnk reported that MSVC ignores unknown flags and still returns 0. This should cause unknown flags to be an error during the compiler check.
Reviewers: rnk
Subscribers: brad.king, llvm-commits
Differential Revision: https://reviews.llvm.org/D23030
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277377 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake/Modules/BuiltinTests.cmake')
-rw-r--r-- | cmake/Modules/BuiltinTests.cmake | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/cmake/Modules/BuiltinTests.cmake b/cmake/Modules/BuiltinTests.cmake index 1b03e94ac..c6da03023 100644 --- a/cmake/Modules/BuiltinTests.cmake +++ b/cmake/Modules/BuiltinTests.cmake @@ -1,3 +1,4 @@ +include(CMakeCheckCompilerFlagCommonPatterns) # This function takes an OS and a list of architectures and identifies the # subset of the architectures list that the installed toolchain can target. @@ -37,7 +38,18 @@ function(try_compile_only output) OUTPUT_VARIABLE TEST_OUTPUT ERROR_VARIABLE TEST_ERROR ) - if(result EQUAL 0) + + CHECK_COMPILER_FLAG_COMMON_PATTERNS(_CheckCCompilerFlag_COMMON_PATTERNS) + foreach(var ${_CheckCCompilerFlag_COMMON_PATTERNS}) + if("${var}" STREQUAL "FAIL_REGEX") + continue() + endif() + if("${var}" MATCHES "${_CheckCCompilerFlag_COMMON_PATTERNS}") + set(ERRORS_FOUND True) + endif() + endforeach() + + if(result EQUAL 0 AND NOT ERRORS_FOUND) set(${output} True PARENT_SCOPE) else() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log |