Skip to content

Commit

Permalink
CMake: Add /WX
Browse files Browse the repository at this point in the history
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 <[email protected]>
Tested-by: Petri Dish Buildbot <[email protected]>
Reviewed-by: Gerald Combs <[email protected]>
  • Loading branch information
geraldcombs committed Oct 16, 2015
1 parent 1ecb4de commit b05803d
Show file tree
Hide file tree
Showing 28 changed files with 88 additions and 67 deletions.
26 changes: 18 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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} )
Expand All @@ -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
Expand Down Expand Up @@ -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)
#
Expand Down Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions capchild/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions caputils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
5 changes: 2 additions & 3 deletions echld/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -92,4 +92,3 @@ if(NOT ${ENABLE_STATIC})
ARCHIVE DESTINATION lib
)
endif()

4 changes: 2 additions & 2 deletions epan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions epan/dissectors/dcerpc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions plugins/docsis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions plugins/ethercat/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions plugins/gryphon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions plugins/irda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions plugins/m2m/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions plugins/mate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions plugins/opcua/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions plugins/profinet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions plugins/stats_tree/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions plugins/tpg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions plugins/unistim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions plugins/wimax/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions plugins/wimaxasncp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions plugins/wimaxmacphy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions tools/lemon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions ui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions ui/gtk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
12 changes: 2 additions & 10 deletions ui/qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
Loading

0 comments on commit b05803d

Please sign in to comment.