This repository has been archived by the owner on Nov 20, 2021. It is now read-only.
forked from NathanFrench/buildem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FortranSupport.cmake
39 lines (32 loc) · 1.56 KB
/
FortranSupport.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Set variables based on current Fortran environment.
# You may then pass these variables into F77 and FFLAGS environment variables.
#
# The following is mostly pulled from the CMakeForFortranExample found here:
# http://www.vtk.org/Wiki/CMakeForFortranExample
if (NOT Fortran_COMPILER_NAME)
enable_language (Fortran)
# FFLAGS depend on the compiler
get_filename_component (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME)
if (Fortran_COMPILER_NAME STREQUAL "gfortran")
# gfortran
set (CMAKE_Fortran_FLAGS_RELEASE "-funroll-all-loops -fno-f2c -O3")
set (CMAKE_Fortran_FLAGS_DEBUG "-fno-f2c -O0 -g")
elseif (Fortran_COMPILER_NAME STREQUAL "ifort")
# ifort (untested)
set (CMAKE_Fortran_FLAGS_RELEASE "-f77rtl -O3")
set (CMAKE_Fortran_FLAGS_DEBUG "-f77rtl -O0 -g")
elseif (Fortran_COMPILER_NAME STREQUAL "g77")
# g77
set (CMAKE_Fortran_FLAGS_RELEASE "-funroll-all-loops -fno-f2c -O3 -m32")
set (CMAKE_Fortran_FLAGS_DEBUG "-fno-f2c -O0 -g -m32")
else (Fortran_COMPILER_NAME STREQUAL "gfortran")
message ("CMAKE_Fortran_COMPILER full path: " ${CMAKE_Fortran_COMPILER})
message ("Fortran compiler: " ${Fortran_COMPILER_NAME})
message ("No optimized Fortran compiler flags are known, we just try -O2...")
set (CMAKE_Fortran_FLAGS_RELEASE "-O2")
set (CMAKE_Fortran_FLAGS_DEBUG "-O0 -g")
endif (Fortran_COMPILER_NAME STREQUAL "gfortran")
message ("Fortran support enabled using ${Fortran_COMPILER_NAME}")
message ("Fortran compiler: ${CMAKE_Fortran_COMPILER}")
message ("Fortran compile flags: ${CMAKE_Fortran_FLAGS_RELEASE}")
endif (NOT Fortran_COMPILER_NAME)