From 4da782ce268a35bab7e08345213a74fd7f6c2ada Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Thu, 16 Jan 2025 10:23:18 -0500 Subject: [PATCH 1/2] Change windows macro for warnings into compiler flags --- Framework/Kernel/inc/MantidKernel/System.h | 22 +++--------------- .../CMake/GenerateMantidExportHeader.cmake | 23 ------------------- buildconfig/CMake/WindowsSetup.cmake | 11 +++++++++ 3 files changed, 14 insertions(+), 42 deletions(-) diff --git a/Framework/Kernel/inc/MantidKernel/System.h b/Framework/Kernel/inc/MantidKernel/System.h index 5ff5cb9b9e18..43c77bc06149 100644 --- a/Framework/Kernel/inc/MantidKernel/System.h +++ b/Framework/Kernel/inc/MantidKernel/System.h @@ -17,30 +17,14 @@ *******************************************************************************/ /* A system-wide file to contain, e.g., useful system-dependent macros - - @author Russell Taylor, Tessella Support Services plc - @date 26/10/2007 -*/ + * + * @author Russell Taylor, Tessella Support Services plc + */ /** * Definitions of the DLLImport compiler directives for MSVC */ #ifdef _WIN32 -// 'identifier' : class 'type' needs to have dll-interface to be used by clients -// of class 'type2' -// Things from the std library give these warnings and we can't do anything -// about them. -#pragma warning(disable : 4251) -// Given that we are compiling everything with msvc under Windows and -// linking all with the same runtime we can disable the warning about -// inheriting from a non-exported interface, e.g. std::runtime_error */ -#pragma warning(disable : 4275) -// Warning C4373: previous versions of the compiler did not override when -// parameters only differed by const/volatile qualifiers -// This is basically saying that it now follows the C++ standard and doesn't -// seem useful -#pragma warning(disable : 4373) - // Export/Import declarations #define DLLExport __declspec(dllexport) #define DLLImport __declspec(dllimport) diff --git a/buildconfig/CMake/GenerateMantidExportHeader.cmake b/buildconfig/CMake/GenerateMantidExportHeader.cmake index ca00c28f2f58..9f81bd5263b8 100644 --- a/buildconfig/CMake/GenerateMantidExportHeader.cmake +++ b/buildconfig/CMake/GenerateMantidExportHeader.cmake @@ -3,29 +3,6 @@ function(GENERATE_MANTID_EXPORT_HEADER TARGET_LIBRARY GENERATE_EXTERN) string(TOUPPER "${TARGET_LIBRARY}" TARGET_NAME) set(CUSTOM "\n") - if(MSVC) - set(CUSTOM - "${CUSTOM}\n\ -#ifdef _WIN32\n\ - // 'identifier' : class 'type' needs to have dll-interface to be used by clients\n\ - // of class 'type2'\n\ - // Things from the std library give these warnings and we can't do anything\n\ - // about them.\n\ - #pragma warning(disable : 4251)\n\ - // Given that we are compiling everything with msvc under Windows and\n\ - // linking all with the same runtime we can disable the warning about\n\ - // inheriting from a non-exported interface, e.g. std::runtime_error */\n\ - #pragma warning(disable : 4275)\n\ - // Warning C4373: previous versions of the compiler did not override when\n\ - // parameters only differed by const/volatile qualifiers\n\ - // This is basically saying that it now follows the C++ standard and doesn't\n\ - // seem useful\n\ - #pragma warning(disable : 4373)\n\ -#endif\n\n\ -" - ) - endif(MSVC) - set(CUSTOM "${CUSTOM}\ #ifndef UNUSED_ARG\n\ diff --git a/buildconfig/CMake/WindowsSetup.cmake b/buildconfig/CMake/WindowsSetup.cmake index 1147a1727afe..de8b8afbef5f 100644 --- a/buildconfig/CMake/WindowsSetup.cmake +++ b/buildconfig/CMake/WindowsSetup.cmake @@ -30,8 +30,19 @@ add_definitions(-D_SILENCE_CXX17_SHARED_PTR_UNIQUE_DEPRECATION_WARNING) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \ /MP /W3 /bigobj \ + /wd4251 /wd4275 /wd4373 \ /experimental:external /external:W0 " ) +# the warnings suppressed are: +# +# 4251 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2' Things from the +# std library give these warnings and we can't do anything about them. +# +# 4275 Given that we are compiling everything with msvc under Windows and linking all with the same runtime we can +# disable the warning about inheriting from a non-exported interface, e.g. std::runtime_error +# +# 4373 previous versions of the compiler did not override when parameters only differed by const/volatile qualifiers. +# This is basically saying that it now follows the C++ standard and doesn't seem useful # Set PCH heap limit, the default does not work when running msbuild from the commandline for some reason Any other # value lower or higher seems to work but not the default. It is fine without this when compiling in the GUI though... From e47801e3d4df5a00c8dbb02cdfacb453de527e05 Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Thu, 16 Jan 2025 12:30:14 -0500 Subject: [PATCH 2/2] Only include some defines if not importing MantidKernel/System.h --- .../CMake/GenerateMantidExportHeader.cmake | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/buildconfig/CMake/GenerateMantidExportHeader.cmake b/buildconfig/CMake/GenerateMantidExportHeader.cmake index 9f81bd5263b8..44c15ef9af62 100644 --- a/buildconfig/CMake/GenerateMantidExportHeader.cmake +++ b/buildconfig/CMake/GenerateMantidExportHeader.cmake @@ -1,17 +1,11 @@ include(GenerateExportHeader) function(GENERATE_MANTID_EXPORT_HEADER TARGET_LIBRARY GENERATE_EXTERN) string(TOUPPER "${TARGET_LIBRARY}" TARGET_NAME) - set(CUSTOM "\n") - set(CUSTOM - "${CUSTOM}\ -#ifndef UNUSED_ARG\n\ - #define UNUSED_ARG(x) (void) x;\n\ -#endif\n\n\ + "\n\ #ifndef ${TARGET_NAME}_DEPRECATED\n\ #define ${TARGET_NAME}_DEPRECATED(func) MANTID_${TARGET_NAME}_DEPRECATED func\n\ -#endif\n\n\ -" +#endif\n\n" ) if(GENERATE_EXTERN) @@ -26,9 +20,18 @@ function(GENERATE_MANTID_EXPORT_HEADER TARGET_LIBRARY GENERATE_EXTERN) // EXTERN_IMPORT is defined in MantidKernel/System.h\n #define EXTERN_MANTID_${TARGET_NAME} EXTERN_IMPORT\n\ #endif /* ${TARGET_LIBRARY}_EXPORTS*/\n\n\ -#include " ) + else() + # UNUSED_ARG is defined and cstdint is included in MantidKernel/System.h + set(CUSTOM + "${CUSTOM}\ +#ifndef UNUSED_ARG\n\ + #define UNUSED_ARG(x) (void) x;\n\ +#endif\n\n\ +#include \n" + ) + endif(GENERATE_EXTERN) generate_export_header(