@@ -28,6 +28,25 @@ option(FLIBCPP_USE_SWIG "Regenerate source files using SWIG" ${FLIBCPP_DEV})
28
28
# FLAGS
29
29
#---------------------------------------------------------------------------#
30
30
31
+ # Fortran standard
32
+ set (FLIBCPP_FORTRAN_STD "03" CACHE STRING
33
+ "Fortran standard for compiling generated code (options: 03/08/15/18)" )
34
+ if (FLIBCPP_FORTRAN_STD AND NOT FLIBCPP_FORTRAN_STD STREQUAL "none" )
35
+ if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" )
36
+ set (_FLIBCPP_STD_FLAGS "-std=f20${FLIBCPP_FORTRAN_STD} " )
37
+ elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" )
38
+ set (_FLIBCPP_STD_FLAGS "-stand ${FLIBCPP_FORTRAN_STD} " )
39
+ else ()
40
+ message (WARNING "Fortran standard flags are not known for "
41
+ "compilier '${CMAKE_Fortran_COMPILER_ID} ': ignoring"
42
+ "FLIBCPP_FORTRAN_STD=${FLIBCPP_FORTRAN_STD} . Configure with "
43
+ "the FFLAGS environment variable or explicitly specify "
44
+ "CMAKE_Fortran_FLAGS" )
45
+ set (_FLIBCPP_STD_FLAGS "none" CACHE FORCE STRING "" )
46
+ endif ()
47
+ endif ()
48
+
49
+ # Build type
31
50
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES )
32
51
if (FLIBCPP_DEV )
33
52
set (_CMAKE_BUILD_TYPE "Debug" )
@@ -38,9 +57,6 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
38
57
set (CMAKE_BUILD_TYPE "${_CMAKE_BUILD_TYPE} " CACHE STRING "Build type" FORCE )
39
58
endif ()
40
59
41
- set (FLIBCPP_FORTRAN_STD "f2003" CACHE STRING
42
- "Fortran standard for compiling generated code" )
43
-
44
60
#---------------------------------------------------------------------------#
45
61
# MODULES TO LOAD
46
62
#---------------------------------------------------------------------------#
@@ -100,7 +116,6 @@ else()
100
116
endif ()
101
117
endif ()
102
118
103
-
104
119
set (FLIBCPP_VERSION_CPP "${CMAKE_CURRENT_BINARY_DIR} /flibcpp_version.cpp" )
105
120
configure_file ("${CMAKE_CURRENT_SOURCE_DIR} /cmake/flibcpp_version.cpp.in"
106
121
"${FLIBCPP_VERSION_CPP} " @ONLY )
@@ -166,11 +181,9 @@ function(flibcpp_add_module name)
166
181
PRIVATE
167
182
cxx_std_11
168
183
)
169
-
170
- if (FLIBCPP_FORTRAN_STD AND CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" )
171
- # Compile Fortran code with given standard
184
+ if (_FLIBCPP_STD_FLAGS )
172
185
target_compile_options (${name}
173
- PUBLIC $< $< COMPILE_LANGUAGE:Fortran> :-std= ${FLIBCPP_FORTRAN_STD }>
186
+ PUBLIC $< $< COMPILE_LANGUAGE:Fortran> :${_FLIBCPP_STD_FLAGS }>
174
187
)
175
188
endif ()
176
189
0 commit comments