C++ feature checks: Filter out warnings caused by user flags

Filter out `-Winvalid-command-line-argument` warnings from Clang (that
can be caused by user-specified flags) so that they do not break our
checks for C++ feature availability.
This commit is contained in:
Brad King 2017-09-19 09:24:20 -04:00
parent eb3abf8b2b
commit 71b65abca2

View File

@ -17,6 +17,8 @@ function(cm_check_cxx_feature name)
set(check_output "${OUTPUT}")
# Filter out MSBuild output that looks like a warning.
string(REGEX REPLACE " +0 Warning\\(s\\)" "" check_output "${check_output}")
# Filter out warnings caused by user flags.
string(REGEX REPLACE "[^\n]*warning:[^\n]*-Winvalid-command-line-argument[^\n]*" "" check_output "${check_output}")
# If using the feature causes warnings, treat it as broken/unavailable.
if(check_output MATCHES "[Ww]arning")
set(CMake_HAVE_CXX_${FEATURE} OFF CACHE INTERNAL "TRY_COMPILE" FORCE)