[PATCH] D23030: [CMake] Don't trust compiler error code, also check for errors
Chris Bieneman via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 1 13:04:31 PDT 2016
beanz created this revision.
beanz added a reviewer: rnk.
beanz added a subscriber: llvm-commits.
rnk reported that MSVC ignores unknown flags and still returns 0. This should cause unknown flags to be an error during the compiler check.
https://reviews.llvm.org/D23030
Files:
cmake/Modules/BuiltinTests.cmake
Index: cmake/Modules/BuiltinTests.cmake
===================================================================
--- cmake/Modules/BuiltinTests.cmake
+++ 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 @@
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("${TEST_OUTPUT}" STREQUAL "FAIL_REGEX")
+ continue()
+ endif()
+ if("${TEST_OUTPUT}" 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23030.66363.patch
Type: text/x-patch
Size: 1025 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160801/d1619594/attachment.bin>
More information about the llvm-commits
mailing list