File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -226,6 +226,30 @@ if(MSVC)
226226 target_compile_options (h5cpp INTERFACE /Zc:__cplusplus )
227227endif ()
228228
229+ # The h5cpp-compiler reflection annotations ([[h5::doc]], [[h5::chunk]],
230+ # [[h5::compress]], [[h5::name]], [[h5::ignore]], ...) live in the `h5::`
231+ # attribute namespace. A plain compiler — i.e. one not running the h5cpp-compiler
232+ # preprocessing pass — does not know that namespace, ignores the attributes, and
233+ # emits -Wattributes for every annotated struct. Declare the namespace
234+ # intentional so consumers that annotate their own types build cleanly. Scoped
235+ # to `h5::` where the compiler supports it (GCC 11+); Clang/older GCC fall back
236+ # to the broader unknown-attribute switch; MSVC silences C5030. Guarded by
237+ # check_cxx_compiler_flag so unsupported toolchains are left untouched. (#291)
238+ if (MSVC )
239+ target_compile_options (h5cpp INTERFACE /wd5030 )
240+ else ()
241+ include (CheckCXXCompilerFlag )
242+ check_cxx_compiler_flag ("-Wno-attributes=h5::" H5CPP_HAS_WNO_ATTRIBUTES_NS )
243+ if (H5CPP_HAS_WNO_ATTRIBUTES_NS)
244+ target_compile_options (h5cpp INTERFACE -Wno-attributes=h5:: )
245+ else ()
246+ check_cxx_compiler_flag ("-Wno-unknown-attributes" H5CPP_HAS_WNO_UNKNOWN_ATTRIBUTES )
247+ if (H5CPP_HAS_WNO_UNKNOWN_ATTRIBUTES)
248+ target_compile_options (h5cpp INTERFACE -Wno-unknown-attributes )
249+ endif ()
250+ endif ()
251+ endif ()
252+
229253if (H5CPP_HAVE_ROS3_VFD)
230254 target_compile_definitions (h5cpp INTERFACE H5CPP_HAVE_ROS3_VFD=1 )
231255endif ()
You can’t perform that action at this time.
0 commit comments