[llvm] r234907 - [msvc] Strip /W[0-4] before appending /W4

Zachary Turner zturner at google.com
Tue Apr 14 09:57:54 PDT 2015


Author: zturner
Date: Tue Apr 14 11:57:54 2015
New Revision: 234907

URL: http://llvm.org/viewvc/llvm-project?rev=234907&view=rev
Log:
[msvc] Strip /W[0-4] before appending /W4

Certain versions of CMake specify /W3 as part of CMAKE_CXX_FLAGS
by default, before you do anything.  Appending /W4 to the end of
this and using the Ninja generator results in

cl : Command line warning D9025 : overriding '/W3' with '/W4'.

It is not possible to suppress this since it is a command line
warning and not a compiler warning, so we must fix the command
line to contain only one value for /Wn.

Modified:
    llvm/trunk/cmake/modules/HandleLLVMOptions.cmake

Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=234907&r1=234906&r2=234907&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake (original)
+++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake Tue Apr 14 11:57:54 2015
@@ -315,6 +315,13 @@ if( MSVC )
   # Enable warnings
   if (LLVM_ENABLE_WARNINGS)
     append("/W4" msvc_warning_flags)
+    # CMake appends /W3 by default, and having /W3 followed by /W4 will result in 
+    # cl : Command line warning D9025 : overriding '/W3' with '/W4'.  Since this is
+    # a command line warning and not a compiler warning, it cannot be suppressed except
+    # by fixing the command line.
+    string(REGEX REPLACE " /W[0-4]" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+    string(REGEX REPLACE " /W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+
     if (LLVM_ENABLE_PEDANTIC)
       # No MSVC equivalent available
     endif (LLVM_ENABLE_PEDANTIC)





More information about the llvm-commits mailing list