1 if(CMAKE_COMPILER_IS_GNUCXX)
3 include(CheckCXXCompilerFlag)
5 # Additional warnings for GCC 6 set(CMAKE_CXX_FLAGS_WARN
"")
7 string(APPEND CMAKE_CXX_FLAGS_WARN
" -Wnon-virtual-dtor")
8 string(APPEND CMAKE_CXX_FLAGS_WARN
" -Wno-long-long")
9 string(APPEND CMAKE_CXX_FLAGS_WARN
" -ansi")
10 string(APPEND CMAKE_CXX_FLAGS_WARN
" -Wcast-align")
11 string(APPEND CMAKE_CXX_FLAGS_WARN
" -Wchar-subscripts")
12 string(APPEND CMAKE_CXX_FLAGS_WARN
" -Wall")
13 string(APPEND CMAKE_CXX_FLAGS_WARN
" -Wextra")
14 string(APPEND CMAKE_CXX_FLAGS_WARN
" -Wpointer-arith")
15 string(APPEND CMAKE_CXX_FLAGS_WARN
" -Wformat-security")
16 string(APPEND CMAKE_CXX_FLAGS_WARN
" -Woverloaded-virtual")
17 string(APPEND CMAKE_CXX_FLAGS_WARN
" -Wshadow")
18 string(APPEND CMAKE_CXX_FLAGS_WARN
" -Wunused-parameter")
19 string(APPEND CMAKE_CXX_FLAGS_WARN
" -fno-check-new")
20 string(APPEND CMAKE_CXX_FLAGS_WARN
" -Werror=undef")
22 # This flag is useful as not returning from a non-void function is an error 23 # with MSVC, but it is not supported on all GCC compiler versions 24 check_cxx_compiler_flag(-Werror=
return-type HAVE_GCC_ERROR_RETURN_TYPE)
25 if(HAVE_GCC_ERROR_RETURN_TYPE)
26 set(CMAKE_CXX_FLAGS_ERROR
"-Werror=return-type")
29 # If we are compiling on Linux then set some extra linker flags too 30 if(CMAKE_SYSTEM_NAME MATCHES
"Linux")
31 option(PARAVIEW_LINKER_FATAL_WARNINGS
"Specify if linker warnings must be considered as errors." OFF)
32 mark_as_advanced(PARAVIEW_LINKER_FATAL_WARNINGS)
33 if(PARAVIEW_LINKER_FATAL_WARNINGS)
34 set(PARAVIEW_EXTRA_SHARED_LINKER_FLAGS
"--fatal-warnings")
36 if (TARGET paraviewbuild)
37 set_target_properties(paraviewbuild
39 INTERFACE_LINK_OPTIONS
40 "LINKER:SHELL:${PARAVIEW_EXTRA_SHARED_LINKER_FLAGS} -lc ${CMAKE_SHARED_LINKER_FLAGS}")
44 # Set up the debug CXX_FLAGS for extra warnings 45 option(PARAVIEW_EXTRA_COMPILER_WARNINGS
46 "Add compiler flags to do stricter checking when building debug." OFF)
47 if(PARAVIEW_EXTRA_COMPILER_WARNINGS)
48 string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO
" ${CMAKE_CXX_FLAGS_WARN}")
49 string(APPEND CMAKE_CXX_FLAGS_DEBUG
50 " ${CMAKE_CXX_FLAGS_WARN} ${CMAKE_CXX_FLAGS_ERROR}")
54 # Intel OneAPI compilers >= 2021.2.0 turn on "fast math" at any non-zero 55 # optimization level. Suppress this non-standard behavior using the 56 # `-fp-model=precise` flag. 57 set(intel_oneapi_compiler_detections)
58 set(intel_oneapi_compiler_version_min
"2021.2.0")
59 foreach (lang IN ITEMS C CXX Fortran)
60 if (CMAKE_VERSION VERSION_LESS
"3.14" AND lang STREQUAL
"Fortran") # XXX(cmake-3.14): `Fortran_COMPILER_ID` genex
63 # Detect the IntelLLVM compiler
for the given
language.
64 set(is_lang
"$<COMPILE_LANGUAGE:${lang}>")
65 set(is_intelllvm
"$<${lang}_COMPILER_ID:IntelLLVM>")
66 set(is_intelllvm_fastmath_assuming_version
"$<VERSION_GREATER_EQUAL:$<${lang}_COMPILER_VERSION>,${intel_oneapi_compiler_version_min}>")
67 list(APPEND intel_oneapi_compiler_detections
68 "$<AND:${is_lang},${is_intelllvm},${is_intelllvm_fastmath_assuming_version}>")
70 string(REPLACE
";" "," intel_oneapi_compiler_detections
"${intel_oneapi_compiler_detections}")
71 if (TARGET paraviewbuild)
72 target_compile_options(paraviewbuild
74 "$<BUILD_INTERFACE:$<$<OR:${intel_oneapi_compiler_detections}>:-fp-model=precise>>")