Skip to content

Commit

Permalink
Use pragma to disable spurious MSVC warning...
Browse files Browse the repository at this point in the history
...rather than doing it at the CMake level
  • Loading branch information
tcbrindle committed Jun 3, 2024
1 parent 3dd9ef6 commit 18d2234
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
7 changes: 0 additions & 7 deletions module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,3 @@ target_sources(flux-mod PUBLIC
target_link_libraries(flux-mod PRIVATE flux)
target_compile_features(flux-mod PUBLIC $<IF:$<CXX_COMPILER_ID:MSVC>,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 <flux.hpp>' in the purview of module 'flux' appears erroneous
)
endif()
11 changes: 11 additions & 0 deletions module/flux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -45,3 +52,7 @@ export module flux;
#ifdef __clang__
#pragma clang diagnostic pop
#endif

#ifdef _MSC_VER
#pragma warning(pop)
#endif
7 changes: 0 additions & 7 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 <flux.hpp>' in the purview of module 'flux' appears erroneous
)
endif()
endif()
endif()

Expand Down

0 comments on commit 18d2234

Please sign in to comment.