-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathgnu.cmake
More file actions
36 lines (30 loc) · 1.77 KB
/
Copy pathgnu.cmake
File metadata and controls
36 lines (30 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
include(CheckCompilerFlag)
# NOTE: don't use -march=native as GCC doesn't support all CPU arches with that option.
# add_compile_options(-mtune=native)
# flags we don't want leaking into child projects to avoid excessive warnings on projects we don't control.
set(gemini3d_flags
$<$<CONFIG:Debug,RelWithDebInfo>:-Wall>
$<$<COMPILE_LANGUAGE:Fortran>:-fimplicit-none>
$<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<VERSION_LESS:$<Fortran_COMPILER_VERSION>,10>>:-Wno-conversion>
$<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<Fortran_COMPILER_VERSION:9.3.0>>:-Wno-maybe-uninitialized>
)
# lot of spurious warnings on allocatable scalar character -Wno-maybe-uninitialized
if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND
CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL "15.0" AND
CMAKE_Fortran_COMPILER_VERSION VERSION_LESS "15.2"
)
list(APPEND gemini3d_flags "$<$<COMPILE_LANGUAGE:Fortran>:-Wno-external-argument-mismatch>")
endif()
# workaround for src/numerical/coord/newton.f90 build fail despite the code being correct.
# https://www.scivision.dev/gfortran-15-external-argument-mismatch/
# --- IMPORTANT
list(APPEND gemini3d_flags "$<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<CONFIG:Debug>>:-Werror=array-bounds$<SEMICOLON>-fcheck=all>")
# --- IMPORTANT: options help trap array indexing/bounds errors at runtime
# avoid backtrace that's unusable without -g
list(APPEND gemini3d_flags "$<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<CONFIG:Release>>:-fno-backtrace>")
# Wdo-subscript is known to warn on obvious non-problems
check_compiler_flag(Fortran -Wdo-subscript dosubflag)
if(dosubflag)
list(APPEND gemini3d_flags $<$<COMPILE_LANGUAGE:Fortran>:-Wno-do-subscript>)
endif()
# add_compile_options("$<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<CONFIG:Debug,RelWithDebInfo>>:-ffpe-trap=invalid,zero,overflow>")#,underflow)