10
10
# Copyright 2011
11
11
#=============================================================================
12
12
13
- macro ( CheckLAPACKCompilerFlags )
13
+ macro (CheckLAPACKCompilerFlags)
14
14
15
- set ( FPE_EXIT FALSE )
16
-
17
- # FORTRAN ILP default
18
- set (FOPT_ILP64)
19
- if ( CMAKE_Fortran_COMPILER_ID MATCHES "Intel" )
20
- if ( WIN32 )
21
- set (FOPT_ILP64 /integer-size:64)
22
- else ()
23
- set (FOPT_ILP64 "-integer-size 64" )
15
+ # FORTRAN ILP default
16
+ set (FOPT_ILP64)
17
+ if (CMAKE_Fortran_COMPILER_ID MATCHES "Intel" )
18
+ if (WIN32 )
19
+ set (FOPT_ILP64 /integer-size:64)
20
+ else ()
21
+ set (FOPT_ILP64 "-integer-size 64" )
24
22
endif ()
25
- elseif ( (CMAKE_Fortran_COMPILER_ID STREQUAL "VisualAge" ) OR # CMake 2.6
26
- (CMAKE_Fortran_COMPILER_ID STREQUAL "XL" ) ) # CMake 2.8
23
+ elseif ((CMAKE_Fortran_COMPILER_ID STREQUAL "VisualAge" ) OR # CMake 2.6
24
+ (CMAKE_Fortran_COMPILER_ID STREQUAL "XL" )) # CMake 2.8
27
25
set (FOPT_ILP64 -qintsize=8)
28
- elseif ( CMAKE_Fortran_COMPILER_ID STREQUAL "NAG" )
29
- if ( WIN32 )
30
- set (FOPT_ILP64 /i8)
31
- else ()
32
- set (FOPT_ILP64 -i8)
26
+ elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "NAG" )
27
+ if ( WIN32 )
28
+ set (FOPT_ILP64 /i8)
29
+ else ()
30
+ set (FOPT_ILP64 -i8)
33
31
endif ()
34
- elseif ( CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC" )
35
- if ( WIN32 )
36
- set (FOPT_ILP64 /i8)
37
- else ()
38
- set (FOPT_ILP64 -i8)
32
+ elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC" )
33
+ if ( WIN32 )
34
+ set (FOPT_ILP64 /i8)
35
+ else ()
36
+ set (FOPT_ILP64 -i8)
39
37
endif ()
40
- else ()
38
+ else ()
41
39
set (CPE_ENV $ENV{PE_ENV} )
42
40
if (CPE_ENV STREQUAL "CRAY" )
43
41
set (FOPT_ILP64 -sinteger64)
@@ -46,210 +44,148 @@ else()
46
44
else ()
47
45
set (FOPT_ILP64 -fdefault-integer-8)
48
46
endif ()
49
- endif ()
50
- if ( FORTRAN_ILP )
51
- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${FOPT_ILP64} " )
52
- endif ()
53
-
54
- # GNU Fortran
55
- if ( CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" )
56
- if ( "${CMAKE_Fortran_FLAGS} " MATCHES "-ffpe-trap=[izoupd]" )
57
- set ( FPE_EXIT TRUE )
58
- endif ()
59
- if ( NOT ("${CMAKE_Fortran_FLAGS} " MATCHES "-frecursive" ) )
60
- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -frecursive"
61
- CACHE STRING "Recursive flag must be set" FORCE)
62
- endif ()
63
-
64
- # Intel Fortran
65
- elseif ( CMAKE_Fortran_COMPILER_ID MATCHES "Intel" )
66
- if ( "${CMAKE_Fortran_FLAGS} " MATCHES "[-/]fpe(-all=|)0" )
67
- set ( FPE_EXIT TRUE )
68
- endif ()
69
-
70
- if ( NOT ("${CMAKE_Fortran_FLAGS} " MATCHES "-recursive" ) )
71
- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -recursive"
72
- CACHE STRING "Recursive flag must be set" FORCE)
73
- endif ()
74
-
75
- if ( UNIX AND NOT ("${CMAKE_Fortran_FLAGS} " MATCHES "-fp-model[ \t ]strict" ) )
76
- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict" )
77
- endif ()
78
-
79
- # SunPro F95
80
- elseif ( CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro" )
81
- if ( ("${CMAKE_Fortran_FLAGS} " MATCHES "-ftrap=" ) AND
82
- NOT ("${CMAKE_Fortran_FLAGS} " MATCHES "-ftrap=(%|)none" ) )
83
- set ( FPE_EXIT TRUE )
84
- elseif ( NOT (CMAKE_Fortran_FLAGS MATCHES "-ftrap=" ) )
85
- message ( STATUS "Disabling FPE trap handlers with -ftrap=%none" )
86
- set ( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ftrap=%none"
87
- CACHE STRING "Flags for Fortran compiler." FORCE )
88
- endif ()
89
-
90
- if (UNIX )
91
- # Delete libmtsk in linking sequence for Sun/Oracle Fortran Compiler.
92
- # This library is not present in the Sun package SolarisStudio12.3-linux-x86-bin
93
- string (REPLACE \;mtsk\; \; CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES "${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES} " )
94
- endif ()
95
-
96
- # IBM XL Fortran
97
- elseif ( (CMAKE_Fortran_COMPILER_ID STREQUAL "VisualAge" ) OR # CMake 2.6
98
- (CMAKE_Fortran_COMPILER_ID STREQUAL "XL" ) ) # CMake 2.8
99
- if ( "${CMAKE_Fortran_FLAGS} " MATCHES "-qflttrap=[a-zA-Z:]:enable" )
100
- set ( FPE_EXIT TRUE )
101
- endif ()
102
-
103
- if ( NOT ("${CMAKE_Fortran_FLAGS} " MATCHES "-qrecur" ) )
104
- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qrecur"
105
- CACHE STRING "Recursive flag must be set" FORCE)
106
47
endif ()
107
-
108
- if ( UNIX AND NOT ("${CMAKE_Fortran_FLAGS} " MATCHES "-qnosave" ) )
109
- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qnosave" )
48
+ if (FORTRAN_ILP)
49
+ add_compile_options ("$<$<COMPILE_LANGUAGE:Fortran>:${FOPT_ILP64} >" )
110
50
endif ()
111
51
52
+ # GNU Fortran
53
+ if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" )
54
+ set (FPE_EXIT_FLAG "-ffpe-trap=[izoupd]" )
112
55
113
- if ( UNIX AND NOT ("${CMAKE_Fortran_FLAGS} " MATCHES "-qstrict" ) )
114
- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qstrict" )
115
- endif ()
116
-
117
- # HP Fortran
118
- elseif ( CMAKE_Fortran_COMPILER_ID STREQUAL "HP" )
119
- if ( "${CMAKE_Fortran_FLAGS} " MATCHES "\\ +fp_exception" )
120
- set ( FPE_EXIT TRUE )
121
- endif ()
56
+ add_compile_options ("$<$<COMPILE_LANGUAGE:Fortran>:-frecursive>" )
122
57
123
- if ( NOT ("${CMAKE_Fortran_FLAGS} " MATCHES "\\ +fltconst_strict" ) )
124
- message ( STATUS "Enabling strict float conversion with +fltconst_strict" )
125
- set ( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} +fltconst_strict"
126
- CACHE STRING "Flags for Fortran compiler." FORCE )
127
- endif ()
128
-
129
- # Most versions of cmake don't have good default options for the HP compiler
130
- set ( CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -g"
131
- CACHE STRING "Flags used by the compiler during debug builds" FORCE )
132
- set ( CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_MINSIZEREL} +Osize"
133
- CACHE STRING "Flags used by the compiler during release minsize builds" FORCE )
134
- set ( CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_RELEASE} +O2"
135
- CACHE STRING "Flags used by the compiler during release builds" FORCE )
136
- set ( CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_RELWITHDEBINFO} +O2 -g"
137
- CACHE STRING "Flags used by the compiler during release with debug info builds" FORCE )
138
-
139
- # NAG Fortran
140
- elseif ( CMAKE_Fortran_COMPILER_ID STREQUAL "NAG" )
141
- if ( "${CMAKE_Fortran_FLAGS} " MATCHES "[-/]ieee=(stop|nonstd)" )
142
- set ( FPE_EXIT TRUE )
143
- endif ()
58
+ # Intel Fortran
59
+ elseif (CMAKE_Fortran_COMPILER_ID MATCHES "Intel" )
60
+ set (FPE_EXIT_FLAG "[-/]fpe(-all=|)0" )
144
61
145
- if ( NOT ("${CMAKE_Fortran_FLAGS} " MATCHES "[-/]ieee=full" ) )
146
- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ieee=full" )
147
- endif ()
148
-
149
- if ( NOT ("${CMAKE_Fortran_FLAGS} " MATCHES "[-/]dcfuns" ) )
150
- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -dcfuns" )
151
- endif ()
152
-
153
- if ( NOT ("${CMAKE_Fortran_FLAGS} " MATCHES "[-/]thread_safe" ) )
154
- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -thread_safe" )
155
- endif ()
156
-
157
- # Disable warnings
158
- if ( NOT ("${CMAKE_Fortran_FLAGS} " MATCHES "[-/]w=obs" ) )
159
- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -w=obs" )
160
- endif ()
161
-
162
- if ( NOT ("${CMAKE_Fortran_FLAGS} " MATCHES "[-/]w=x77" ) )
163
- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -w=x77" )
164
- endif ()
165
-
166
- if ( NOT ("${CMAKE_Fortran_FLAGS} " MATCHES "[-/]w=ques" ) )
167
- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -w=ques" )
168
- endif ()
169
-
170
- if ( NOT ("${CMAKE_Fortran_FLAGS} " MATCHES "[-/]w=unused" ) )
171
- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -w=unused" )
172
- endif ()
173
-
174
- if ( NOT ("${CMAKE_Fortran_FLAGS} " MATCHES "-recursive" ) )
175
- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -recursive"
176
- CACHE STRING "Recursive flag must be set" FORCE)
177
- endif ()
62
+ add_compile_options ("$<$<COMPILE_LANGUAGE:Fortran>:-recursive>" )
63
+ if (UNIX )
64
+ add_compile_options ("$<$<COMPILE_LANGUAGE:Fortran>:-fp-model strict>" )
65
+ endif ()
178
66
179
- # Suppress compiler banner and summary
180
- include (CheckFortranCompilerFlag)
181
- check_fortran_compiler_flag("-quiet" _quiet)
182
- if ( _quiet AND NOT ("${CMAKE_Fortran_FLAGS} " MATCHES "[-/]quiet" ) )
183
- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -quiet" )
184
- endif ()
67
+ # SunPro F95
68
+ elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro" )
69
+ set (FPE_EXIT_FLAG "-ftrap=" )
70
+ set (FPE_DISABLE_FLAG "-ftrap=(%|)none" )
185
71
186
- # NVIDIA HPC SDK
187
- elseif ( CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC" )
188
- if ( ("${CMAKE_Fortran_FLAGS} " MATCHES "-Ktrap=" ) AND
189
- NOT ("${CMAKE_Fortran_FLAGS} " MATCHES "-Ktrap=none" ) )
190
- set ( FPE_EXIT TRUE )
191
- endif ()
72
+ message (STATUS "Disabling FPE trap handlers with -ftrap=%none" )
73
+ add_compile_options ("$<$<COMPILE_LANGUAGE:Fortran>:-ftrap=%none>" )
192
74
193
- if ( NOT ("${CMAKE_Fortran_FLAGS} " MATCHES "[-/]Kieee" ) )
194
- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Kieee" )
195
- endif ()
75
+ if (UNIX )
76
+ # Delete libmtsk in linking sequence for Sun/Oracle Fortran Compiler.
77
+ # This library is not present in the Sun package SolarisStudio12.3-linux-x86-bin
78
+ string (REPLACE \;mtsk\; \; CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES
79
+ "${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES} " )
80
+ endif ()
196
81
197
- if ( NOT ( " ${CMAKE_Fortran_FLAGS} " MATCHES "-Mrecursive" ) )
198
- set (CMAKE_Fortran_FLAGS " ${CMAKE_Fortran_FLAGS} -Mrecursive"
199
- CACHE STRING "Recursive flag must be set" FORCE)
200
- endif ( )
82
+ # IBM XL Fortran
83
+ elseif ((CMAKE_Fortran_COMPILER_ID STREQUAL "VisualAge" ) OR # CMake 2.6
84
+ (CMAKE_Fortran_COMPILER_ID STREQUAL "XL" )) # CMake 2.8
85
+ set (FPE_EXIT_FLAG "-qflttrap=[a-zA-Z:]:enable" )
201
86
202
- # Flang Fortran
203
- elseif ( CMAKE_Fortran_COMPILER_ID STREQUAL "Flang" )
204
- if ( NOT ("${CMAKE_Fortran_FLAGS} " MATCHES "-Mrecursive" ) )
205
- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Mrecursive"
206
- CACHE STRING "Recursive flag must be set" FORCE)
207
- endif ()
87
+ add_compile_options ("$<$<COMPILE_LANGUAGE:Fortran>:-qrecur>" )
88
+ if (UNIX )
89
+ add_compile_options ("$<$<COMPILE_LANGUAGE:Fortran>:-qnosave>" )
90
+ add_compile_options ("$<$<COMPILE_LANGUAGE:Fortran>:-qstrict>" )
91
+ endif ()
208
92
209
- # Compaq Fortran
210
- elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "Compaq" )
211
- if (WIN32 )
212
- if (CMAKE_GENERATOR STREQUAL "NMake Makefiles" )
213
- get_filename_component (CMAKE_Fortran_COMPILER_CMDNAM ${CMAKE_Fortran_COMPILER} NAME_WE )
214
- message (STATUS "Using Compaq Fortran compiler with command name ${CMAKE_Fortran_COMPILER_CMDNAM} " )
215
- set (cmd ${CMAKE_Fortran_COMPILER_CMDNAM} )
216
- string (TOLOWER "${cmd} " cmdlc)
217
- if (cmdlc STREQUAL "df" )
218
- message (STATUS "Assume the Compaq Visual Fortran Compiler is being used" )
219
- set (CMAKE_Fortran_USE_RESPONSE_FILE_FOR_OBJECTS 1)
220
- set (CMAKE_Fortran_USE_RESPONSE_FILE_FOR_INCLUDES 1)
221
- #This is a workaround that is needed to avoid forward-slashes in the
222
- #filenames listed in response files from incorrectly being interpreted as
223
- #introducing compiler command options
224
- if (${BUILD_SHARED_LIBS} )
225
- message (FATAL_ERROR "Making of shared libraries with CVF has not been tested." )
93
+ # HP Fortran
94
+ elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "HP" )
95
+ set (FPE_EXIT_FLAG "\\ +fp_exception" )
96
+
97
+ message (STATUS "Enabling strict float conversion with +fltconst_strict" )
98
+ add_compile_options ("$<$<COMPILE_LANGUAGE:Fortran>:+fltconst_strict>" )
99
+
100
+ # Most versions of cmake don't have good default options for the HP compiler
101
+ add_compile_options ("$<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<CONFIG:DEBUG>>:-g>" )
102
+ add_compile_options ("$<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<CONFIG:MINSIZEREL>>:+Osize>" )
103
+ add_compile_options ("$<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<CONFIG:RELEASE>>:+O2>" )
104
+ add_compile_options ("$<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<CONFIG:RELWITHDEBINFO>>:+O2 -g>" )
105
+
106
+ # NAG Fortran
107
+ elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "NAG" )
108
+ set (FPE_EXIT_FLAG "[-/]ieee=(stop|nonstd)" )
109
+
110
+ add_compile_options ("$<$<COMPILE_LANGUAGE:Fortran>:-ieee=full>" )
111
+ add_compile_options ("$<$<COMPILE_LANGUAGE:Fortran>:-dcfuns>" )
112
+ add_compile_options ("$<$<COMPILE_LANGUAGE:Fortran>:-thread_safe>" )
113
+ add_link_options ("$<$<COMPILE_LANGUAGE:Fortran>:-thread_safe>" )
114
+ add_compile_options ("$<$<COMPILE_LANGUAGE:Fortran>:-recursive>" )
115
+
116
+ # Disable warnings
117
+ add_compile_options ("$<$<COMPILE_LANGUAGE:Fortran>:-w=obs>" )
118
+ add_compile_options ("$<$<COMPILE_LANGUAGE:Fortran>:-w=x77>" )
119
+ add_compile_options ("$<$<COMPILE_LANGUAGE:Fortran>:-w=ques>" )
120
+ add_compile_options ("$<$<COMPILE_LANGUAGE:Fortran>:-w=unused>" )
121
+
122
+ # Suppress compiler banner and summary
123
+ include (CheckFortranCompilerFlag)
124
+ check_fortran_compiler_flag("-quiet" _quiet)
125
+ add_compile_options ("$<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<BOOL:${_quiet} >>:-quiet>" )
126
+ add_link_options ("$<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<BOOL:${_quiet} >>:-quiet>" )
127
+
128
+ # NVIDIA HPC SDK
129
+ elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC" )
130
+ set (FPE_EXIT_FLAG "-Ktrap=" )
131
+ set (FPE_DISABLE_FLAG "-Ktrap=none" )
132
+
133
+ add_compile_options ("$<$<COMPILE_LANGUAGE:Fortran>:-Kieee>" )
134
+ add_compile_options ("$<$<COMPILE_LANGUAGE:Fortran>:-Mrecursive>" )
135
+
136
+ # Flang Fortran
137
+ elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "Flang" )
138
+ add_compile_options ("$<$<COMPILE_LANGUAGE:Fortran>:-Mrecursive>" )
139
+
140
+ # Compaq Fortran
141
+ elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "Compaq" )
142
+ if (WIN32 )
143
+ if (CMAKE_GENERATOR STREQUAL "NMake Makefiles" )
144
+ get_filename_component (CMAKE_Fortran_COMPILER_CMDNAM ${CMAKE_Fortran_COMPILER} NAME_WE )
145
+ message (STATUS "Using Compaq Fortran compiler with command name ${CMAKE_Fortran_COMPILER_CMDNAM} " )
146
+ set (cmd ${CMAKE_Fortran_COMPILER_CMDNAM} )
147
+ string (TOLOWER "${cmd} " cmdlc)
148
+ if (cmdlc STREQUAL "df" )
149
+ message (STATUS "Assume the Compaq Visual Fortran Compiler is being used" )
150
+ set (CMAKE_Fortran_USE_RESPONSE_FILE_FOR_OBJECTS 1)
151
+ set (CMAKE_Fortran_USE_RESPONSE_FILE_FOR_INCLUDES 1)
152
+ #This is a workaround that is needed to avoid forward-slashes in the
153
+ #filenames listed in response files from incorrectly being interpreted as
154
+ #introducing compiler command options
155
+ if (${BUILD_SHARED_LIBS} )
156
+ message (FATAL_ERROR "Making of shared libraries with CVF has not been tested." )
157
+ endif ()
158
+ set (str "NMake version 9 or later should be used. NMake version 6.0 which is\n " )
159
+ set (str "${str} included with the CVF distribution fails to build Lapack because\n " )
160
+ set (str "${str} the number of source files exceeds the limit for NMake v6.0\n " )
161
+ message (STATUS ${str} )
162
+ set (CMAKE_Fortran_LINK_EXECUTABLE "LINK /out:<TARGET> <LINK_FLAGS> <LINK_LIBRARIES> <OBJECTS>" )
226
163
endif ()
227
- set (str "NMake version 9 or later should be used. NMake version 6.0 which is\n " )
228
- set (str "${str} included with the CVF distribution fails to build Lapack because\n " )
229
- set (str "${str} the number of source files exceeds the limit for NMake v6.0\n " )
230
- message (STATUS ${str} )
231
- set (CMAKE_Fortran_LINK_EXECUTABLE "LINK /out:<TARGET> <LINK_FLAGS> <LINK_LIBRARIES> <OBJECTS>" )
232
164
endif ()
233
165
endif ()
234
- endif ()
235
166
236
- else ()
237
- message (WARNING "Fortran local arrays should be allocated on the stack."
238
- " Please use a compiler which guarantees that feature."
239
- " See https://github.com/Reference-LAPACK/lapack/pull/188 and references therein." )
240
- endif ()
167
+ else ()
168
+ message (WARNING "Fortran local arrays should be allocated on the stack."
169
+ " Please use a compiler which guarantees that feature."
170
+ " See https://github.com/Reference-LAPACK/lapack/pull/188 and references therein." )
171
+ endif ()
241
172
242
- if ( "${CMAKE_Fortran_FLAGS_RELEASE} " MATCHES "O[3-9]" )
243
- message ( STATUS "Reducing RELEASE optimization level to O2" )
244
- string ( REGEX REPLACE "O[3-9]" "O2" CMAKE_Fortran_FLAGS_RELEASE
245
- "${CMAKE_Fortran_FLAGS_RELEASE} " )
246
- set ( CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} "
247
- CACHE STRING "Flags used by the compiler during release builds" FORCE )
248
- endif ()
173
+ if ("${CMAKE_Fortran_FLAGS_RELEASE} " MATCHES "O[3-9]" )
174
+ message (STATUS "Reducing RELEASE optimization level to O2" )
175
+ string (REGEX REPLACE "O[3-9]" "O2" CMAKE_Fortran_FLAGS_RELEASE
176
+ "${CMAKE_Fortran_FLAGS_RELEASE} " )
177
+ endif ()
249
178
179
+ # Get all flags added via `add_compile_options(...)`
180
+ get_directory_property (COMP_OPTIONS COMPILE_OPTIONS)
250
181
251
- if ( FPE_EXIT )
252
- message ( FATAL_ERROR "Floating Point Exception (FPE) trap handlers are currently explicitly enabled in the compiler flags. LAPACK is designed to check for and handle these cases internally and enabling these traps will likely cause LAPACK to crash. Please re-configure with floating point exception trapping disabled." )
253
- endif ()
182
+ if (("${CMAKE_Fortran_FLAGS} ;${COMP_OPTIONS} " MATCHES "${FPE_EXIT_FLAG} " ) AND NOT
183
+ ("${CMAKE_Fortran_FLAGS} ;${COMP_OPTIONS} " MATCHES "${FPE_DISABLE_FLAG} " ))
184
+ message ( FATAL_ERROR "Floating Point Exception (FPE) trap handlers are"
185
+ " currently explicitly enabled in the compiler flags. LAPACK is designed"
186
+ " to check for and handle these cases internally and enabling these traps"
187
+ " will likely cause LAPACK to crash. Please re-configure with floating"
188
+ " point exception trapping disabled." )
189
+ endif ()
254
190
255
191
endmacro ()
0 commit comments