From 18d2234089fe663657337fbd65bfc6f2973fe41e Mon Sep 17 00:00:00 2001 From: Tristan Brindle Date: Mon, 3 Jun 2024 14:02:00 +0100 Subject: [PATCH] Use pragma to disable spurious MSVC warning... ...rather than doing it at the CMake level --- module/CMakeLists.txt | 7 ------- module/flux.cpp | 11 +++++++++++ test/CMakeLists.txt | 7 ------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/module/CMakeLists.txt b/module/CMakeLists.txt index 0203601b..c7b12142 100644 --- a/module/CMakeLists.txt +++ b/module/CMakeLists.txt @@ -17,10 +17,3 @@ target_sources(flux-mod PUBLIC target_link_libraries(flux-mod PRIVATE flux) target_compile_features(flux-mod PUBLIC $,cxx_std_23,cxx_std_20>) set_target_properties(flux-mod PROPERTIES CXX_EXTENSIONS Off) - -# Squish MSVC warning when building the module, hopefully we're not actually doing anything wrong -if(MSVC) - target_compile_options(flux-mod PRIVATE - /wd5244 # '#include ' in the purview of module 'flux' appears erroneous - ) -endif() \ No newline at end of file diff --git a/module/flux.cpp b/module/flux.cpp index 92332b10..0c22215c 100644 --- a/module/flux.cpp +++ b/module/flux.cpp @@ -33,6 +33,13 @@ export module flux; #define FLUX_MODULE_INTERFACE +// Silence Clang and MSVC warnings about #include inside a module's purview + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 5244) +#endif + #ifdef __clang__ #pragma clang diagnostic push #if __has_warning("-Winclude-angled-in-module-purview") @@ -45,3 +52,7 @@ export module flux; #ifdef __clang__ #pragma clang diagnostic pop #endif + +#ifdef _MSC_VER +#pragma warning(pop) +#endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 960cabd5..7f7e58b0 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -112,13 +112,6 @@ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.28.0") target_compile_definitions(test-flux PRIVATE -DUSE_MODULES) set_target_properties(test-flux PROPERTIES CXX_SCAN_FOR_MODULES On) - - # Squish MSVC warning when building the module, hopefully we're not actually doing anything wrong - if(MSVC) - target_compile_options(test-flux PRIVATE - /wd5244 # '#include ' in the purview of module 'flux' appears erroneous - ) - endif() endif() endif()