1
+ if ( NOT Fortran_FLAGS_INIT )
2
+ set ( Fortran_FLAGS_INIT TRUE )
3
+ set ( CALL_STACK_BACK_TRACE TRUE CACHE BOOL
4
+ "Enable backtraces on unexpected runtime errors? (Recommended)" )
5
+ set ( ENABLE_COMPILE_TIME_WARNINGS TRUE CACHE BOOL
6
+ "Enable diagnostic warnings at compile time? (Recommended)" )
7
+ set ( ENABLE_RUNTIME_CHECKS FALSE CACHE BOOL
8
+ "Enable compiler run-time checks? (Enabling this will turn off most compiler optimizations.)" )
9
+ mark_as_advanced ( ENABLE_RUNTIME_CHECKS )
10
+
11
+ if ( "${CMAKE_Fortran_COMPILER_ID} " MATCHES "Intel" )
12
+ if ( CALL_STACK_BACK_TRACE )
13
+ add_compile_options ( -traceback )
14
+ endif ( CALL_STACK_BACK_TRACE )
15
+ if ( ENABLE_COMPILE_TIME_WARNINGS )
16
+ # The following warning might be triggered by ifort unless explicitly silenced:
17
+ # warning #7601: F2008 standard does not allow an internal procedure to be an actual argument procedure
18
+ # name. (R1214.4). In the context of F2008 this is an erroneous warning.
19
+ # See https://prd1idz.cps.intel.com/en-us/forums/topic/486629
20
+ add_compile_options ( -warn -stand f08 -diag-disable 7601 )
21
+ endif ( ENABLE_COMPILE_TIME_WARNINGS )
22
+ if ( ENABLE_RUNTIME_CHECKS )
23
+ add_compile_options ( -check all )
24
+ endif ( ENABLE_RUNTIME_CHECKS )
25
+ elseif ( "{CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU" )
26
+ if ( CALL_STACK_BACK_TRACE )
27
+ add_compile_options ( -fbacktrace )
28
+ endif ( CALL_STACK_BACK_TRACE )
29
+ if ( ENABLE_COMPILETIME_CHECKS )
30
+ add_compile_options ( -Wall -Wextra -Wno-maybe-uninitialized -pedantic -std=f2008 )
31
+ endif ( ENABLE_COMPILETIME_CHECKS )
32
+ if ( ENABLE_RUNTIME_CHECKS )
33
+ add_compile_options ( -fcheck=all )
34
+ endif ( ENABLE_RUNTIME_CHECKS )
35
+ endif ( "${CMAKE_Fortran_COMPILER_ID} " MATCHES "Intel" )
36
+ endif ( NOT Fortran_FLAGS_INIT )
0 commit comments