CMake: Add /WX
authorGerald Combs <gerald@wireshark.org>
Tue, 15 Sep 2015 00:19:02 +0000 (17:19 -0700)
committerGerald Combs <gerald@wireshark.org>
Fri, 16 Oct 2015 21:32:22 +0000 (21:32 +0000)
Add "/WX" to the Visual C++ compiler flags if DISABLE_WERROR is off,
similar to config.nmake.

We haven't compiled C++ code with -Wshorten-64-to-32 for quite
some time so there's no need to add -Wno-shorten-64-to-32 in
ui/qt/CMakeLists.txt.

Additionally, squelch

----
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\algorithm(3050) : warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data (.\rpc_service_response_time_dialog.cpp)
        C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\algorithm(3065) : see reference to function template instantiation 'void std::_Median<_RanIt,bool(__cdecl *)(const QString &,const QString &)>(_RanIt,_RanIt,_RanIt,_Pr)' being compiled
        with
        [
            _RanIt=QList<QString>::iterator
,            _Pr=bool (__cdecl *)(const QString &,const QString &)
        ]
        C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\algorithm(3127) : see reference to function template instantiation 'std::pair<_RanIt,_RanIt> std::_Unguarded_partition<_RanIt,bool(__cdecl *)(const QString &,const QString &)>(_RanIt,_RanIt,_Pr)' being compiled
        with
        [
            _RanIt=QList<QString>::iterator
,            _Pr=bool (__cdecl *)(const QString &,const QString &)
        ]
        C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\algorithm(3157) : see reference to function template instantiation 'void std::_Sort<_Iter,int,bool(__cdecl *)(const QString &,const QString &)>(_RanIt,_RanIt,_Diff,_Pr)' being compiled
        with
        [
            _Iter=QList<QString>::iterator
,            _RanIt=QList<QString>::iterator
,            _Diff=int
,            _Pr=bool (__cdecl *)(const QString &,const QString &)
        ]
        .\rpc_service_response_time_dialog.cpp(130) : see reference to function template instantiation 'void std::sort<QList<QString>::iterator,bool(__cdecl *)(const QString &,const QString &)>(_RanIt,_RanIt,_Pr)' being compiled
        with
        [
            _RanIt=QList<QString>::iterator
,            _Pr=bool (__cdecl *)(const QString &,const QString &)
        ]
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\algorithm(3051) : warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data (.\rpc_service_response_time_dialog.cpp)
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\algorithm(3052) : warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data (.\rpc_service_response_time_dialog.cpp)
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\algorithm(3053) : warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data (.\rpc_service_response_time_dialog.cpp)
----

in both rpc_service_response_time_dialog.cpp and wireshark_application.cpp
so that we'll compile successfully.

Change-Id: I457bcede99dcb1f3c1001f1f559c4901bb000357
Reviewed-on: https://code.wireshark.org/review/10533
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
28 files changed:
CMakeLists.txt
capchild/CMakeLists.txt
caputils/CMakeLists.txt
echld/CMakeLists.txt
epan/CMakeLists.txt
epan/dissectors/dcerpc/CMakeLists.txt
plugins/docsis/CMakeLists.txt
plugins/ethercat/CMakeLists.txt
plugins/gryphon/CMakeLists.txt
plugins/irda/CMakeLists.txt
plugins/m2m/CMakeLists.txt
plugins/mate/CMakeLists.txt
plugins/opcua/CMakeLists.txt
plugins/profinet/CMakeLists.txt
plugins/stats_tree/CMakeLists.txt
plugins/tpg/CMakeLists.txt
plugins/unistim/CMakeLists.txt
plugins/wimax/CMakeLists.txt
plugins/wimaxasncp/CMakeLists.txt
plugins/wimaxmacphy/CMakeLists.txt
tools/lemon/CMakeLists.txt
ui/CMakeLists.txt
ui/gtk/CMakeLists.txt
ui/qt/CMakeLists.txt
ui/qt/rpc_service_response_time_dialog.cpp
ui/qt/wireshark_application.cpp
wiretap/CMakeLists.txt
wsutil/CMakeLists.txt

index 7f234acf28a423913bdff1cd57d47fb651075b14..06aab57ae7a043379a0075d97d5b34a62c85adc1 100644 (file)
@@ -496,12 +496,6 @@ set( CPP_FLAG_TESTS ${WIRESHARK_COMMON_FLAGS} ${WIRESHARK_CPP_ONLY_FLAGS} )
 include(CheckCCompilerFlag)
 include(CheckCXXCompilerFlag)
 
-if(NOT DISABLE_WERROR AND NOT ENABLE_EXTRA_COMPILER_WARNINGS)
-       check_c_compiler_flag(-Werror WERROR)
-else()
-       set(WERROR FALSE)
-endif()
-
 # Sigh: Have to use THIS_FLAG instead of ${F} for some reason
 foreach(THIS_FLAG ${C_FLAG_TESTS})
        string( REGEX REPLACE "[^a-zA-Z0-9_]+" "_" F ${THIS_FLAG} )
@@ -527,6 +521,21 @@ foreach(THIS_FLAG ${CPP_FLAG_TESTS})
 endforeach()
 set(CMAKE_CXX_FLAGS "${ADDED_CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
 
+if(NOT DISABLE_WERROR AND NOT ENABLE_EXTRA_COMPILER_WARNINGS)
+       if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
+               set(WERROR_COMMON_FLAGS "/WX")
+               set(NO_ERROR_DEPRECATED_DECLARATIONS_COMPILE_FLAGS)
+       else()
+               check_c_compiler_flag(-Werror WERROR)
+               if (WERROR)
+                       set(WERROR_COMMON_FLAGS "-Werror")
+                       set(NO_ERROR_DEPRECATED_DECLARATIONS_COMPILE_FLAGS "-Wno-error=deprecated-declarations")
+               endif()
+       endif()
+else()
+       set(WERROR_COMMON_FLAGS FALSE)
+endif()
+
 #
 # Try to have the compiler default to hiding symbols, so that only
 # symbols explicitly exported with WS_DLL_PUBLIC will be visible
@@ -915,6 +924,7 @@ endif()
 
 message(STATUS "C-Flags: ${CMAKE_C_FLAGS}")
 message(STATUS "CXX-Flags: ${CMAKE_CXX_FLAGS}")
+message(STATUS "Warnings as errors: ${WERROR_COMMON_FLAGS}")
 
 if(APPLE)
        #
@@ -2418,11 +2428,11 @@ set(CLEAN_FILES
        ${androiddump_FILES}
 )
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${CLEAN_FILES}
                PROPERTIES
-               COMPILE_FLAGS -Werror
+               COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
        )
 endif()
 
index cc94e47d3f341293ba92ccf00441f038a858ef17..64b6edeb700d75eba1c21511d3a6031c2cfd8100 100644 (file)
@@ -29,11 +29,11 @@ set(CLEAN_FILES
        ${CAPCHILD_SRC}
 )
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${CLEAN_FILES}
                PROPERTIES
-               COMPILE_FLAGS -Werror
+               COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
        )
 endif()
 
index 3bf314f98aacbc444653a69b8b59fe7d6e582912..4f6a9ef1305b909dd840042705b90bf184e4009d 100644 (file)
@@ -52,11 +52,11 @@ set(CLEAN_FILES
        ${CAPUTILS_SRC}
 )
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${CLEAN_FILES}
                PROPERTIES
-               COMPILE_FLAGS -Werror
+               COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
        )
 endif()
 
index a7e3701be4223f9df2ad8ded7705baacbf478ad1..257c301598e481376f943eb199311baffc0d4ce2 100644 (file)
@@ -39,11 +39,11 @@ set(ECHLD_FILES
        ${DIRTY_FILES}
 )
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${CLEAN_FILES}
                PROPERTIES
-               COMPILE_FLAGS -Werror
+               COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
        )
 endif()
 
@@ -92,4 +92,3 @@ if(NOT ${ENABLE_STATIC})
                ARCHIVE DESTINATION lib
        )
 endif()
-
index 1d600f487be9ced52f4d0dbea64f19db2a4ef5de..29785efa9ad5ebffbf948b61b4121f461e190b99 100644 (file)
@@ -1725,11 +1725,11 @@ set(CLEAN_FILES
        ${WSLUA_FILES}
 )
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${CLEAN_FILES}
                PROPERTIES
-               COMPILE_FLAGS -Werror
+               COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
        )
 endif()
 
index ee2077ea0e8c06bd09bb43ee3bcf53bdf78b0d39..276357cb75eaa373b544baea26b4e2a9f6b03325 100644 (file)
@@ -34,11 +34,11 @@ set(CLEAN_FILES
        ${IDL2WRS_FILES}
 )
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${CLEAN_FILES}
                PROPERTIES
-               COMPILE_FLAGS -Werror
+               COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
        )
 endif()
 
index ad8c04df7f943c1e6af61a53bc4e11860043b7fc..73b9ea76fbf4223ac57471256561e7b29f272fc4 100644 (file)
@@ -81,11 +81,11 @@ set(CLEAN_FILES
        ${PLUGIN_FILES}
 )
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${CLEAN_FILES}
                PROPERTIES
-               COMPILE_FLAGS -Werror
+               COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
        )
 endif()
 
index 8acba1d1202051456b52eca4a1804041cec511ed..446885241c23f47de08d3ecd5e8d2a311d76a2ef 100644 (file)
@@ -43,11 +43,11 @@ set(CLEAN_FILES
        ${PLUGIN_FILES}
 )
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${CLEAN_FILES}
                PROPERTIES
-               COMPILE_FLAGS -Werror
+               COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
        )
 endif()
 
index 78dd816207492a3d8addab51e95117a79544e956..80805482043d08f44a14cd51e8d512523cddd96f 100644 (file)
@@ -37,11 +37,11 @@ set(CLEAN_FILES
        ${PLUGIN_FILES}
 )
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${CLEAN_FILES}
                PROPERTIES
-               COMPILE_FLAGS -Werror
+               COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
        )
 endif()
 
index b2575ae28c849d2634368deea4f0c7df9096151b..ad10505e9ddcd87223314164aed7b02625fbab04 100644 (file)
@@ -39,11 +39,11 @@ set(CLEAN_FILES
        ${PLUGIN_FILES}
 )
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${CLEAN_FILES}
                PROPERTIES
-               COMPILE_FLAGS -Werror
+               COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
        )
 endif()
 
index aa9c7b8a699c78cb31388ff2e1fff4a70bac2f2b..ed6c423dd440298f9d669959ce383bf576fecd4f 100644 (file)
@@ -42,11 +42,11 @@ set(CLEAN_FILES
        ${PLUGIN_FILES}
 )
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${CLEAN_FILES}
                PROPERTIES
-               COMPILE_FLAGS -Werror
+               COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
        )
 endif()
 
index 9e8e54d5495f02480a48ba2bc58e4acae22ad4f8..666dd1b240513dca0b526796c0d0006b60e769e3 100644 (file)
@@ -60,11 +60,11 @@ set(CLEAN_FILES
        ${DISSECTOR_SUPPORT_CLEAN_SRC}
 )
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${CLEAN_FILES}
                PROPERTIES
-               COMPILE_FLAGS -Werror
+               COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
        )
 endif()
 
index 685c765c88c18bde02cbc6d820966d280c9c5afa..812e92fb5a89eca40b5879739368ce4cf43bbe18 100644 (file)
@@ -52,11 +52,11 @@ set(CLEAN_FILES
        ${PLUGIN_FILES}
 )
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${CLEAN_FILES}
                PROPERTIES
-               COMPILE_FLAGS -Werror
+               COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
        )
 endif()
 
index a672997329f8178072fc39314e82217108201db5..2dc6139430ba519dfa153cc5c9f76b3e4f6f0a65 100644 (file)
@@ -49,11 +49,11 @@ set(CLEAN_FILES
        ${PLUGIN_FILES}
 )
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${CLEAN_FILES}
                PROPERTIES
-               COMPILE_FLAGS -Werror
+               COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
        )
 endif()
 
index 160661137b82e5ff17c38926a0e19bdd3e0b78f7..b7a4e60a47591bffebd198d5a5dcc0d07cc9ca7e 100644 (file)
@@ -33,11 +33,11 @@ set(CLEAN_FILES
        ${PLUGIN_FILES}
 )
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${CLEAN_FILES}
                PROPERTIES
-               COMPILE_FLAGS -Werror
+               COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
        )
 endif()
 
index 5e7b5bd301b25c8712cf959b5fdc0844269ec56d..61bde023923d97f0279157360057339d468fedd1 100644 (file)
@@ -33,11 +33,11 @@ set(CLEAN_FILES
        ${PLUGIN_FILES}
 )
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${CLEAN_FILES}
                PROPERTIES
-               COMPILE_FLAGS -Werror
+               COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
        )
 endif()
 
index 5f700f7ec0b42b2e46a186bb8b73ae2ceaf798f6..0725c3f4ea4b309722049bea05ac465fb3cba1c9 100644 (file)
@@ -37,11 +37,11 @@ set(CLEAN_FILES
        ${PLUGIN_FILES}
 )
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${CLEAN_FILES}
                PROPERTIES
-               COMPILE_FLAGS -Werror
+               COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
        )
 endif()
 
index 73d46e88ae4e933ae0fbada64480416051699aed..77af623ba9ccdf39046b0b7ab4780fa3f5cdf1e6 100644 (file)
@@ -82,11 +82,11 @@ set(CLEAN_FILES
        ${PLUGIN_FILES}
 )
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${CLEAN_FILES}
                PROPERTIES
-               COMPILE_FLAGS -Werror
+               COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
        )
 endif()
 
index 46113d91d9a5fb2655ba2c6d61b576073edce640..d3b781975204ce37480b8805c8962b1e51891690 100644 (file)
@@ -37,11 +37,11 @@ set(CLEAN_FILES
        ${PLUGIN_FILES}
 )
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${CLEAN_FILES}
                PROPERTIES
-               COMPILE_FLAGS -Werror
+               COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
        )
 endif()
 
index 736ed9d316d91af49c797e8d87bd4abe543f8492..49b32df350a2bbc2910f95227b3a670765982413 100644 (file)
@@ -37,11 +37,11 @@ set(CLEAN_FILES
        ${PLUGIN_FILES}
 )
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${CLEAN_FILES}
                PROPERTIES
-               COMPILE_FLAGS -Werror
+               COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
        )
 endif()
 
index d0b7cb84aea54abb7736bb413e50227995d948bb..f76cfe1f18da3485ef980270221cfdeca2eb43e3 100644 (file)
@@ -27,11 +27,11 @@ set(CLEAN_FILES
        ${lemon_FILES}
 )
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${CLEAN_FILES}
                PROPERTIES
-               COMPILE_FLAGS -Werror
+               COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
        )
 endif()
 
index 55831df5203d0a4596585b258383f959ec082418..fa714f6fc3e9a25180b57fbd7e29acbfc2192b08 100644 (file)
@@ -81,11 +81,11 @@ set(CLEAN_FILES
        ${COMMON_UI_SRC}
 )
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${CLEAN_FILES}
                PROPERTIES
-               COMPILE_FLAGS -Werror
+               COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
        )
 endif()
 
index de9a0aaad6d172cb42c670be59aad7979af3d29c..371801ca936860d002042dc2a3bcc5c960912621 100644 (file)
@@ -232,11 +232,11 @@ set(CLEAN_FILES
        ${WIRESHARK_TAP_SRC}
 )
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${CLEAN_FILES}
                PROPERTIES
-               COMPILE_FLAGS "-Werror -Wno-error=deprecated-declarations"
+               COMPILE_FLAGS "${WERROR_COMMON_FLAGS} ${NO_ERROR_DEPRECATED_DECLARATIONS_COMPILE_FLAGS}"
        )
 endif()
 
index ed3d0a5e5998ea99dc24c120986803447a4c429c..d39be1ca973655e0960c880f0c5330ae5f3cfbf0 100644 (file)
@@ -468,20 +468,12 @@ else()
        # set_target_properties(${some-source-files} PROPERTIES AUTOMOC TRUE)
 endif()
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${WIRESHARK_QT_FILES}
                PROPERTIES
-               COMPILE_FLAGS -Werror
+               COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
        )
-       # The Qt headers generate a ton of shortening errors on 64-bit systems.
-       if (CMAKE_SIZEOF_VOID_P EQUAL 8)
-               set_source_files_properties(
-                       ${WIRESHARK_QT_FILES}
-                       PROPERTIES
-                       COMPILE_FLAGS -Wno-shorten-64-to-32
-               )
-       endif()
 endif()
 
 add_definitions(${QT_DEFINITIONS})
index 50253275bd18f31f223bbc3e9a83ab0d63165fc9..7b492aa43f391193d7ea6c7ed3020600beb17fe8 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+// warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable : 4267)
+#endif
+
 #include "rpc_service_response_time_dialog.h"
 
 #include <algorithm>
 #include <QHBoxLayout>
 #include <QLabel>
 
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
 // To do:
 // - Don't assume that the user knows what programs+versions are in the
 //   capture. I.e. combine this dialog with the ONC-RPC Programs dialog,
index 1a516a02fe21b324699c96eb28a58811a2c50bdd..083d3fde0dda3001051256a04393b742e1dc2a97 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+// warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable : 4267)
+#endif
+
 #include "wireshark_application.h"
 
 #include <algorithm>
 #include <QLibrary>
 #endif
 
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
 WiresharkApplication *wsApp = NULL;
 
 // XXX - Copied from ui/gtk/file_dlg.c
index 328012fd13a40543f0b1b45ad81fa77471e8faa3..e3eb20aa6fdcb6ea9751bf4395dc95775099f9a9 100644 (file)
@@ -81,11 +81,11 @@ set(WIRETAP_FILES
        wtap.c
 )
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${WIRETAP_FILES}
                PROPERTIES
-               COMPILE_FLAGS -Werror
+               COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
        )
 endif()
 
index 364de2fc77e9fc41417b0c821e07f2b9c36bb5a9..d8870fe041a25d18add667120225c842f98d1b4f 100644 (file)
@@ -180,11 +180,11 @@ set(CLEAN_FILES
        ${WSUTIL_FILES}
 )
 
-if (WERROR)
+if (WERROR_COMMON_FLAGS)
        set_source_files_properties(
                ${CLEAN_FILES}
                PROPERTIES
-               COMPILE_FLAGS -Werror
+               COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
        )
 else()
        #