1+ set (CMAKE_CONFIGURATION_TYPES "Release;RelWithDebInfo;Debug" CACHE STRING "Build type selections" FORCE )
2+
13if (CMAKE_Fortran_COMPILER_ID STREQUAL Intel)
2- if (NOT WIN32 )
3- string (APPEND CMAKE_Fortran_FLAGS " -march= native - stand f18 - traceback - warn - heap-arrays" )
4- else ()
5- string (APPEND CMAKE_Fortran_FLAGS " /arch: native / stand: f18 / traceback / warn / heap-arrays" )
4+ if (WIN32 )
5+ string (APPEND CMAKE_Fortran_FLAGS " /arch: native / stand: f18 / traceback / warn / heap-arrays" )
6+ else ()
7+ string (APPEND CMAKE_Fortran_FLAGS " -march= native - stand f18 - traceback - warn - heap-arrays" )
68 endif ()
79elseif (CMAKE_Fortran_COMPILER_ID STREQUAL GNU)
10+ string (APPEND CMAKE_Fortran_FLAGS " -Wall -Wextra -fimplicit-none" )
11+ string (APPEND CMAKE_Fortran_FLAGS_DEBUG " -fcheck=all -Werror=array-bounds" )
12+ # -march=native is not for all CPU arches with GCC.
13+ add_compile_options (-mtune=native )
14+
815 if (CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 8)
916 string (APPEND CMAKE_Fortran_FLAGS " -std=f2018" )
1017 endif ()
11- # not mtune=native for CPU compatibility
12- string (APPEND CMAKE_Fortran_FLAGS " -mtune=native -fimplicit-none -Wall -Wextra" )
13- string (APPEND CMAKE_Fortran_FLAGS_DEBUG " -ffpe-trap=overflow -Warray-bounds" )
1418elseif (CMAKE_Fortran_COMPILER_ID STREQUAL PGI)
1519 string (APPEND CMAKE_Fortran_FLAGS " -C -Mdclchk" )
20+ elseif (CMAKE_Fortran_COMPILER_ID STREQUAL Flang)
21+ string (APPEND CMAKE_Fortran_FLAGS " -W" )
1622elseif (CMAKE_Fortran_COMPILER_ID STREQUAL NAG)
1723 string (APPEND CMAKE_Fortran_FLAGS " -f2018 -C -colour -gline -nan -info -u" )
1824endif ()
1925
26+ include (CheckFortranSourceCompiles )
27+ check_fortran_source_compiles ("implicit none (external); end" f2018impnone SRC_EXT f90 )
28+ if (NOT f2018impnone)
29+ message (FATAL_ERROR "Compiler does not support Fortran 2018 IMPLICIT NONE (EXTERNAL): ${CMAKE_Fortran_COMPILER_ID} ${CMAKE_Fortran_COMPILER_VERSION } " )
30+ endif ()
31+
2032include (CheckFortranSourceRuns )
2133check_fortran_source_runs ("use, intrinsic :: ieee_arithmetic, only: ieee_value, ieee_quiet_nan, ieee_is_nan
2234real :: r
2335r = ieee_value(1., ieee_quiet_nan)
2436if (.not.ieee_is_nan(r)) error stop
25- end program" f03nan )
37+ end program" f03nan )
0 commit comments