Jelajahi Sumber

C++ feature checks: Improve exclusion of "0 Warning(s)"

Simply matching "0 Warning" may match "10 Warning(s)".  Instead remove
the entire `    0 Warning(s)` content from the MSBuild output before
searching it for warnings.

Issue: #16942
Brad King 8 tahun lalu
induk
melakukan
f44d9bcc8f
1 mengubah file dengan 3 tambahan dan 1 penghapusan
  1. 3 1
      Source/Checks/cm_cxx_features.cmake

+ 3 - 1
Source/Checks/cm_cxx_features.cmake

@@ -14,8 +14,10 @@ function(cm_check_cxx_feature name)
       CMAKE_FLAGS ${maybe_cxx_standard}
       CMAKE_FLAGS ${maybe_cxx_standard}
       OUTPUT_VARIABLE OUTPUT
       OUTPUT_VARIABLE OUTPUT
       )
       )
+    # Filter out MSBuild output that looks like a warning.
+    string(REGEX REPLACE " +0 Warning\\(s\\)" "" check_output "${OUTPUT}")
     # If using the feature causes warnings, treat it as broken/unavailable.
     # If using the feature causes warnings, treat it as broken/unavailable.
-    if(OUTPUT MATCHES "[Ww]arning" AND NOT OUTPUT MATCHES "0 Warning")
+    if(check_output MATCHES "[Ww]arning")
       set(CMake_HAVE_CXX_${FEATURE} OFF CACHE INTERNAL "TRY_COMPILE" FORCE)
       set(CMake_HAVE_CXX_${FEATURE} OFF CACHE INTERNAL "TRY_COMPILE" FORCE)
     endif()
     endif()
     if(CMake_HAVE_CXX_${FEATURE})
     if(CMake_HAVE_CXX_${FEATURE})