Browse Source

CMakeDetermineCompilerABI: Avoid failing on warnings with -Werror

Simply remove `-Werror` flags from `CMAKE_<LANG>_FLAGS` to avoid failing
ABI detection if there happen to be warnings in the test project.  For
example, `-Wunused-command-line-argument` warnings are common since the
ABI detection project may not exercise all the flags passed by users.

Fixes: #20305
David Rohr 5 years ago
parent
commit
d5895f50c3
1 changed files with 3 additions and 0 deletions
  1. 3 0
      Modules/CMakeDetermineCompilerABI.cmake

+ 3 - 0
Modules/CMakeDetermineCompilerABI.cmake

@@ -32,6 +32,9 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src)
     endif()
     __TestCompiler_setTryCompileTargetType()
 
+    # Avoid failing ABI detection on warnings.
+    string(REGEX REPLACE "(^| )-Werror(=[^ ]*)?( |$)" " " CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}")
+
     # Save the current LC_ALL, LC_MESSAGES, and LANG environment variables
     # and set them to "C" that way GCC's "search starts here" text is in
     # English and we can grok it.