diff --git a/CMakeLists.txt b/CMakeLists.txt index c03ec08d85..8e2b2bd90b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -202,15 +202,6 @@ set(NACL_VM_INHERITED_OPTIONS "${DEFAULT_NACL_VM_INHERITED_OPTIONS}" CACHE STRIN "Semicolon-separated list of options for which NaCl game VMs should use the same value as the other binaries") mark_as_advanced(NACL_VM_INHERITED_OPTIONS) -if (BE_VERBOSE) - set(WARNMODE "no-error=") -else() - set(WARNMODE "no-") -endif() -if (DAEMON_PARENT_SCOPE_DIR) - set(WARNMODE ${WARNMODE} PARENT_SCOPE) -endif() - ################################################################################ # Directories ################################################################################ @@ -287,7 +278,12 @@ endif() include(DaemonFlags) -# Warning options +# Warning options (for Daemon only) +# Note the different scopes used for warning options: +# * set_c_cxx_flag(xxx) or try_c_cxx_flag(xxx) sets it for all code including dependencies +# * try_flag(WARNINGS xxx) in DaemonFlags.cmake sets it for Daemon and Unvanquished but not deps +# * try_flag(WARNINGS xxx) below sets it for Daemon only + try_flag(WARNINGS "-Wshadow=local") try_flag(WARNINGS "-Wno-pragmas") try_flag(WARNINGS "-Wno-unknown-pragmas") @@ -296,6 +292,14 @@ try_flag(WARNINGS "-Woverloaded-virtual") try_flag(WARNINGS "-Wstrict-null-sentinel") try_flag(WARNINGS "-W${WARNMODE}sign-compare") +# MSVC /wd = warning disable +try_flag(WARNINGS "/wd4127") # conditional expression is constant +try_flag(WARNINGS "/wd4324") # 'XXX': structure was padded due to alignment specifier +try_flag(WARNINGS "/wd4458") # declaration of 'XXX' hides class member +try_flag(WARNINGS "/wd4459") # declaration of 'XXX' hides global declaration +try_flag(WARNINGS "/wd4701") # potentially uninitialized local variable 'XXX' used +try_flag(WARNINGS "/wd26495") # Variable 'XXX' is uninitialized. Always initialize a member variable. + ################################################################################ # Group the sources by folder to have folder show in Visual Studio ################################################################################ diff --git a/cmake/DaemonFlags.cmake b/cmake/DaemonFlags.cmake index d77f15c851..a850ce806e 100644 --- a/cmake/DaemonFlags.cmake +++ b/cmake/DaemonFlags.cmake @@ -116,6 +116,12 @@ macro(try_linker_flag PROP FLAG) endif() endmacro() +if (BE_VERBOSE) + set(WARNMODE "no-error=") +else() + set(WARNMODE "no-") +endif() + option(USE_CPU_RECOMMENDED_FEATURES "Use some common hardware features like SSE2, NEON, VFP, MCX16, etc." ON) if(MINGW AND USE_BREAKPAD) @@ -159,6 +165,14 @@ if (MSVC) endif() set_linker_flag("/LARGEADDRESSAWARE") + # These warnings need to be disabled for both Daemon and Unvanquished since they are triggered in shared headers + try_flag(WARNINGS "/wd4201") # nonstandard extension used: nameless struct / union + try_flag(WARNINGS "/wd4244") # 'XXX': conversion from 'YYY' to 'ZZZ', possible loss of data + try_flag(WARNINGS "/wd4267") # 'initializing' : conversion from 'size_t' to 'int', possible loss of data + + # This warning is garbage because it doesn't go away if you parenthesize the expression + try_flag(WARNINGS "/wd4706") # assignment within conditional expression + # Turn off warning C4996:, e.g: # warning C4996: 'open': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _open. See online help for details. set_c_cxx_flag("/wd4996") # open seems far more popular than _open not to mention nicer. There doesn't seem to be any reason or will to change to _open. diff --git a/src/common/Compiler.h b/src/common/Compiler.h index 1aba7c1200..6b8fc45940 100644 --- a/src/common/Compiler.h +++ b/src/common/Compiler.h @@ -132,23 +132,6 @@ inline int CountTrailingZeroes(unsigned long long x) { return __builtin_ctzll(x) // Microsoft Visual C++ #elif defined( _MSC_VER ) -// Disable some warnings -#pragma warning(disable : 4127) // conditional expression is constant - -#pragma warning(disable : 4201) // nonstandard extension used: nameless struct / union -#pragma warning(disable : 4244) // 'XXX': conversion from 'YYY' to 'ZZZ', possible loss of data -#pragma warning(disable : 4267) // 'initializing' : conversion from 'size_t' to 'int', possible loss of data - -#pragma warning(disable : 4324) // 'refBone_t': structure was padded due to alignment specifier - -#pragma warning(disable : 4458) // declaration of 'XXX' hides class member -#pragma warning(disable : 4459) // declaration of 'XXX' hides global declaration - -#pragma warning(disable : 4701) // potentially uninitialized local variable 'XXX' used -#pragma warning(disable : 4706) // assignment within conditional expression - -#pragma warning(disable : 26495) // Variable 'XXX' is uninitialized. Always initialize a member variable. - // See descriptions above #define DEPRECATED __declspec(deprecated) #define WARN_UNUSED_RESULT _Check_return_