[vtkusers] A fix for MSVC warning D9025: overriding '/W1' with '/w'

Niels Dekker - address until 2018 niels_dekker_address_until_2018 at xs4all.nl
Sun Sep 20 05:20:30 EDT 2015


When building VTK within Microsoft Visual Studio, I always get many 
(20+) 'D9025' warnings, saying:

   "cl : Command line warning D9025: overriding '/W1' with '/w'"

These warnings appear useless and distracting to me. Can someone 
please fix this issue?

The issue can be fixed by using '/W0', instead of '-w' or '/w', to 
disable MSVC warnings. It should be fixed in the following six files:

   CMake\vtkModuleMacros.cmake
   CMake\vtkThirdParty.cmake
   ThirdParty\xdmf2\vtkxdmf2\CMake\vtkThirdParty.cmake
   ThirdParty\exodusII\vtkexodusII\CMakeLists.txt
   ThirdParty\hdf5\vtkhdf5\CMakeLists.txt
   ThirdParty\netcdf\vtknetcdf\CMakeLists.txt

I encountered these warnings on any version of VTK, CMake, and Visual 
Studio that I tried recently, including the latest releases, VTK 
6.3.0, CMake 3.3.2, and Visual Studio 2015 (but also Visual Studio 2010).

ITK used to have the same issue. My fix for the ITK issue was included 
with ITK 4.8.0. It was discussed at the ITK users mailing list: 
http://public.kitware.com/pipermail/community/2015-February/008349.html My 
ITK patch is at: http://review.source.kitware.com/#/c/19311/

A patch (unified diff) for VTK is hereby attached. Can someone please 
commit + push it to Kitware's VTK GIT, for me?

Kind regards, Niels
-- 
Niels Dekker
Scientific programmer
LKEB, Division of Image Processing
Leiden University Medical Center
-------------- next part --------------
 CMake/vtkModuleMacros.cmake                         | 3 ++-
 CMake/vtkThirdParty.cmake                           | 6 +++---
 ThirdParty/exodusII/vtkexodusII/CMakeLists.txt      | 6 +++---
 ThirdParty/hdf5/vtkhdf5/CMakeLists.txt              | 8 ++++----
 ThirdParty/netcdf/vtknetcdf/CMakeLists.txt          | 8 ++++----
 ThirdParty/xdmf2/vtkxdmf2/CMake/vtkThirdParty.cmake | 6 +++---
 6 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/CMake/vtkModuleMacros.cmake b/CMake/vtkModuleMacros.cmake
index 556d4b1..cbc00e8 100644
--- a/CMake/vtkModuleMacros.cmake
+++ b/CMake/vtkModuleMacros.cmake
@@ -374,7 +374,8 @@ function(vtk_module_warnings_disable)
   foreach(lang IN LISTS ARGN)
     if(MSVC)
       string(REGEX REPLACE "(^| )[/-]W[0-4]( |$)" " "
-        CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} -w")
+        CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}")
+      set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} /W0")
     elseif(BORLAND)
       set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} -w-")
     else()
diff --git a/CMake/vtkThirdParty.cmake b/CMake/vtkThirdParty.cmake
index 0f58a1a..277f127 100644
--- a/CMake/vtkThirdParty.cmake
+++ b/CMake/vtkThirdParty.cmake
@@ -1,13 +1,13 @@
 #-----------------------------------------------------------------------------
 MACRO(VTK_THIRD_PARTY_WARNING_SUPPRESS upper lang)
   IF(NOT ${upper}_WARNINGS_ALLOW)
-    # MSVC uses /w to suppress warnings.  It also complains if another
-    # warning level is given, so remove it.
+    # Visual Studio generators of CMake use /W0 to suppress warnings. 
+    # MSVC complains if another warning level is given, so remove it.
     IF(MSVC)
       SET(${upper}_WARNINGS_BLOCKED 1)
       STRING(REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " "
         CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}")
-      SET(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} /w")
+      SET(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} /W0")
     ENDIF()
 
     # Borland uses -w- to suppress warnings.
diff --git a/ThirdParty/exodusII/vtkexodusII/CMakeLists.txt b/ThirdParty/exodusII/vtkexodusII/CMakeLists.txt
index 870742f..1d2efa8 100644
--- a/ThirdParty/exodusII/vtkexodusII/CMakeLists.txt
+++ b/ThirdParty/exodusII/vtkexodusII/CMakeLists.txt
@@ -20,13 +20,13 @@ OPTION (EXODUSII_DISABLE_COMPILER_WARNINGS "Disable compiler warnings" ON)
 MARK_AS_ADVANCED(EXODUSII_DISABLE_COMPILER_WARNINGS)
 
 IF (EXODUSII_DISABLE_COMPILER_WARNINGS)
-  # MSVC uses /w to suppress warnings.  It also complains if another
-  # warning level is given, so remove it.
+  # Visual Studio generators of CMake use /W0 to suppress warnings. 
+  # MSVC complains if another warning level is given, so remove it.
   IF (MSVC)
     SET (EXODUSII_WARNINGS_BLOCKED 1)
     STRING (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " "
         CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
-    SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /w")
+    SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W0")
   ENDIF ()
   IF(WIN32)
     ADD_DEFINITIONS (-D_CRT_SECURE_NO_WARNINGS)
diff --git a/ThirdParty/hdf5/vtkhdf5/CMakeLists.txt b/ThirdParty/hdf5/vtkhdf5/CMakeLists.txt
index 6f89861..bee625c 100644
--- a/ThirdParty/hdf5/vtkhdf5/CMakeLists.txt
+++ b/ThirdParty/hdf5/vtkhdf5/CMakeLists.txt
@@ -445,14 +445,14 @@ endif (HDF5_ENABLE_EMBEDDED_LIBINFO)
 #-----------------------------------------------------------------------------
 option (HDF5_DISABLE_COMPILER_WARNINGS "Disable compiler warnings" OFF)
 if (HDF5_DISABLE_COMPILER_WARNINGS)
-  # MSVC uses /w to suppress warnings.  It also complains if another
-  # warning level is given, so remove it.
+  # Visual Studio generators of CMake use /W0 to suppress warnings. 
+  # MSVC complains if another warning level is given, so remove it.
   if (MSVC)
     set (HDF5_WARNINGS_BLOCKED 1)
     string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
-    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /w")
+    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W0")
     string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
-    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /w")
+    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0")
   endif (MSVC)
   if (WIN32)
     add_definitions (-D_CRT_SECURE_NO_WARNINGS)
diff --git a/ThirdParty/netcdf/vtknetcdf/CMakeLists.txt b/ThirdParty/netcdf/vtknetcdf/CMakeLists.txt
index 974e82f..4ed8168 100644
--- a/ThirdParty/netcdf/vtknetcdf/CMakeLists.txt
+++ b/ThirdParty/netcdf/vtknetcdf/CMakeLists.txt
@@ -270,15 +270,15 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/ncconfig.h.in
 OPTION (NETCDF_DISABLE_COMPILER_WARNINGS "Disable compiler warnings" ON)
 MARK_AS_ADVANCED(NETCDF_DISABLE_COMPILER_WARNINGS)
 IF (NETCDF_DISABLE_COMPILER_WARNINGS)
-  # MSVC uses /w to suppress warnings.  It also complains if another
-  # warning level is given, so remove it.
+  # Visual Studio generators of CMake use /W0 to suppress warnings. 
+  # MSVC complains if another warning level is given, so remove it.
   IF (MSVC)
     STRING (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " "
         CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
     STRING (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " "
         CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
-    SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /w")
-    SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /w")
+    SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W0")
+    SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0")
   # Borland uses -w- to suppress warnings.
   ELSEIF (BORLAND)
     SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-")
diff --git a/ThirdParty/xdmf2/vtkxdmf2/CMake/vtkThirdParty.cmake b/ThirdParty/xdmf2/vtkxdmf2/CMake/vtkThirdParty.cmake
index 8af7ab4..63caa10 100644
--- a/ThirdParty/xdmf2/vtkxdmf2/CMake/vtkThirdParty.cmake
+++ b/ThirdParty/xdmf2/vtkxdmf2/CMake/vtkThirdParty.cmake
@@ -55,13 +55,13 @@ ENDMACRO()
 #-----------------------------------------------------------------------------
 MACRO(VTK_THIRD_PARTY_WARNING_SUPPRESS upper lang)
   IF(NOT ${upper}_WARNINGS_ALLOW)
-    # MSVC uses /w to suppress warnings.  It also complains if another
-    # warning level is given, so remove it.
+    # Visual Studio generators of CMake use /W0 to suppress warnings. 
+    # MSVC complains if another warning level is given, so remove it.
     IF(MSVC)
       SET(${upper}_WARNINGS_BLOCKED 1)
       STRING(REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " "
         CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}")
-      SET(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} /w")
+      SET(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} /W0")
     ENDIF()
 
     # Borland uses -w- to suppress warnings.


More information about the vtkusers mailing list