ParaViewCompilerWarningFlags.cmake
Go to the documentation of this file.
1 # Silence spurious -Wattribute warnings on GCC < 9.1:
2 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89325
3 if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
4  CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.1)
5  target_compile_options(paraviewbuild
6  INTERFACE
7  "$<BUILD_INTERFACE:$<$<COMPILE_LANGUAGE:C>:-Wno-attributes>>"
8  "$<BUILD_INTERFACE:$<$<COMPILE_LANGUAGE:CXX>:-Wno-attributes>>")
9 endif ()
10 
11 # This module requires CMake 3.19 features (the `CheckCompilerFlag`
12 # module). Just skip it for older CMake versions.
13 if (CMAKE_VERSION VERSION_LESS "3.19")
14  return()
15 endif ()
16 
17 include(CheckCompilerFlag)
18 
19 function(paraview_add_flag flag)
20  foreach (lang IN LISTS ARGN)
21  check_compiler_flag("${lang}" "${flag}" "paraview_have_compiler_flag-${lang}-${flag}")
22  if (paraview_have_compiler_flag-${lang}-${flag})
23  target_compile_options(paraviewbuild
24  INTERFACE
25  "$<BUILD_INTERFACE:$<$<COMPILE_LANGUAGE:${lang}>:${flag}>>")
26  endif ()
27  endforeach ()
28 endfunction()
29 
30 option(PARAVIEW_ENABLE_EXTRA_BUILD_WARNINGS "Enable extra build warnings" OFF)
31 mark_as_advanced(PARAVIEW_ENABLE_EXTRA_BUILD_WARNINGS)
32 
33 if (PARAVIEW_ENABLE_EXTRA_BUILD_WARNINGS)
34  # C and C++ flags.
35  set(langs C CXX)
36  # Ignored warnings. Should be investigated and false positives reported to
37  # GCC and actual bugs fixed.
38  paraview_add_flag(-Wno-stringop-overflow ${langs}) # VTK issue 19306
39  paraview_add_flag(-Wno-stringop-overread ${langs}) # VTK issue 19307
40  paraview_add_flag(-Wno-vla-extension ${langs})
41 endif ()
lang
function paraview_add_flag(flag)