From: Matthias Maier Date: Sun, 2 Aug 2015 23:01:28 +0000 (-0500) Subject: CMake: Refactor configuration for MSVC's compiler warning X-Git-Tag: v8.4.0-rc2~687^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e82bd9eb48f230d691b86f1bcbfa662949b8786;p=dealii.git CMake: Refactor configuration for MSVC's compiler warning Those configuration should go to setup_compiler_flags_msvc.cmake and not into the config.h header file... --- diff --git a/cmake/setup_compiler_flags.cmake b/cmake/setup_compiler_flags.cmake index ed35485116..3dc72be873 100644 --- a/cmake/setup_compiler_flags.cmake +++ b/cmake/setup_compiler_flags.cmake @@ -32,6 +32,12 @@ # DEAL_II_LINKER_FLAGS # DEAL_II_LINKER_FLAGS_DEBUG # DEAL_II_LINKER_FLAGS_RELEASE +# DEAL_II_DEFINITIONS +# DEAL_II_DEFINITIONS_DEBUG +# DEAL_II_DEFINITIONS_RELEASE +# DEAL_II_USER_DEFINITIONS +# DEAL_II_USER_DEFINITIONS_DEBUG +# DEAL_II_USER_DEFINITIONS_RELEASE # # All modifications shall be guarded with the ENABLE_IF_SUPPORTED # or ENABLE_IF_LINKS macro, e.g. diff --git a/cmake/setup_compiler_flags_msvc.cmake b/cmake/setup_compiler_flags_msvc.cmake index d23b5e455f..bb5b8c45d3 100644 --- a/cmake/setup_compiler_flags_msvc.cmake +++ b/cmake/setup_compiler_flags_msvc.cmake @@ -30,14 +30,44 @@ # enable exception handling: ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "/EHsc") -#enable warnings: -ADD_FLAGS(DEAL_II_CXX_FLAGS "/W3") # Globally disable some legacy min and max macros that cause problems: ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "/NOMINMAX") +LIST(APPEND DEAL_II_DEFINITIONS "NOMINMAX") +LIST(APPEND DEAL_II_USER_DEFINITIONS "NOMINMAX") + +ADD_FLAGS(DEAL_II_CXX_FLAGS "/W3") -# Disable warning about unknown pragmas +# +# Selectively disable a bunch of warnings: +# +# 4068 - unknown pragmas +# 4244 - implied downcasting from double to float +# 4267 - implied downcasting from size_t to unsigned int +# 4996 - unsafe functions, such as strcat and sprintf +# 4355 - 'this' : used in base member initializer list +# 4661 - no suitable definition provided for explicit template instantiation request +# 4800 - forcing value to bool 'true' or 'false' (performance warning) +# 4146 - unary minus operator applied to unsigned type, result still unsigned +# 4667 - no function template defined that matches forced instantiation +# 4520 - multiple default constructors specified +# 4700 - uninitialized local variable +# 4789 - destination of memory copy is too small +# 4808 - case 'value' is not a valid value for switch condition of type 'bool ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "/wd4068") +ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "/wd4244") +ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "/wd4267") +ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "/wd4996") +ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "/wd4355") +ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "/wd4661") +ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "/wd4800") +ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "/wd4146") +ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "/wd4667") +ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "/wd4520") +ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "/wd4700") +ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "/wd4789") +ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "/wd4808") + ############################# # # diff --git a/include/deal.II/base/config.h.in b/include/deal.II/base/config.h.in index 09fbfb319c..0d756e943d 100644 --- a/include/deal.II/base/config.h.in +++ b/include/deal.II/base/config.h.in @@ -131,29 +131,6 @@ #cmakedefine DEAL_II_MSVC -/* - * Disable a bunch of warnings for Microsoft Visual C++. - */ -#ifdef _MSC_VER -# pragma warning( disable : 4244 ) /* implied downcasting from double to float */ -# pragma warning( disable : 4267 ) /* implied downcasting from size_t to unsigned int */ -# pragma warning( disable : 4996 ) /* unsafe functions, such as strcat and sprintf */ -# pragma warning( disable : 4355 ) /* 'this' : used in base member initializer list */ -# pragma warning( disable : 4661 ) /* no suitable definition provided for explicit template instantiation request */ -# pragma warning( disable : 4800 ) /* forcing value to bool 'true' or 'false' (performance warning) */ -# pragma warning( disable : 4146 ) /* unary minus operator applied to unsigned type, result still unsigned */ -# pragma warning( disable : 4667 ) /* no function template defined that matches forced instantiation */ -# pragma warning( disable : 4520 ) /* multiple default constructors specified */ -# pragma warning( disable : 4700 ) /* uninitialized local variable */ -# pragma warning( disable : 4789 ) /* destination of memory copy is too small */ -# pragma warning( disable : 4808 ) /* case 'value' is not a valid value for switch condition of type 'bool */ -/* - * Also make sure we don't let MS Windows headers define min/max as - * macros, see http://support.microsoft.com/kb/143208 - */ -# define NOMINMAX -#endif /*_MSC_VER*/ - /*********************************************************************** * Thread support