Skip to content

Commit

Permalink
Add options for traps and checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
cianciosa committed Sep 9, 2024
1 parent f0f5fb5 commit 2d1d2ff
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,50 @@ register_sanitizer_option (thread OFF)
register_sanitizer_option (undefined ON)
register_sanitizer_option (float-divide-by-zero ON)

#-------------------------------------------------------------------------------
# Trap options
#-------------------------------------------------------------------------------
add_library (traps INTERFACE)

macro (register_trap_option name)
string (TOUPPER ${name} upper_name)

option (TRAP_${upper_name} "Enable the ${name} trap" OFF)

target_compile_options (traps
INTERFACE
$<$<AND:$<BOOL:${TRAP_${upper_name}}>,$<Fortran_COMPILER_ID:GNU>,$<COMPILE_LANGUAGE:Fortran>>:-ffpe-trap=${name}>
)
endmacro ()

register_trap_option (invalid)
register_trap_option (zero)
register_trap_option (overflow)
register_trap_option (inexact)
register_trap_option (denormal)

#-------------------------------------------------------------------------------
# Trap options
#-------------------------------------------------------------------------------
add_library (checks INTERFACE)

macro (register_checks_option name)
string (TOUPPER ${name} upper_name)

option (CHECK_${upper_name} "Enable the ${name} checks" OFF)

target_compile_options (checks
INTERFACE
$<$<AND:$<BOOL:${CHECK_${upper_name}}>,$<Fortran_COMPILER_ID:GNU>,$<COMPILE_LANGUAGE:Fortran>>:-fcheck=${name}>
)
endmacro ()

register_checks_option (recursion)
register_checks_option (pointer)
register_checks_option (mem)
register_checks_option (do)
register_checks_option (bounds)

#-------------------------------------------------------------------------------
# Setup access method.
#-------------------------------------------------------------------------------
Expand Down

0 comments on commit 2d1d2ff

Please sign in to comment.