-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathcompilers.cmake
More file actions
54 lines (48 loc) · 1.9 KB
/
Copy pathcompilers.cmake
File metadata and controls
54 lines (48 loc) · 1.9 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
include(CheckFortranSourceCompiles)
include(CheckFortranSourceRuns)
include(CheckFortranCompilerFlag)
# === check that the compiler has adequate Fortran 2008 support
# this is to mitigate confusing syntax error messages for new users
check_fortran_source_compiles("implicit none (type, external); end" f2018impnone SRC_EXT f90)
if(NOT f2018impnone)
message(FATAL_ERROR "Compiler does not support Fortran 2018 IMPLICIT NONE (type, external): ${CMAKE_Fortran_COMPILER_ID} ${CMAKE_Fortran_COMPILER_VERSION}")
endif()
check_fortran_source_compiles("block; end block; end" f2008block SRC_EXT f90)
if(NOT f2008block)
message(FATAL_ERROR "Compiler does not support Fortran 2008 BLOCK syntax: ${CMAKE_Fortran_COMPILER_ID} ${CMAKE_Fortran_COMPILER_VERSION}")
endif()
check_fortran_source_compiles("
module A
interface
module subroutine C
end subroutine
end interface
end module
submodule (A) B
contains
module procedure C
end procedure
end submodule
program D
end program" f2008submodule SRC_EXT f90)
if(NOT f2008submodule)
message(FATAL_ERROR "Compiler does not support Fortran 2008 SUBMODULE syntax: ${CMAKE_Fortran_COMPILER_ID} ${CMAKE_Fortran_COMPILER_VERSION}")
endif()
# Do these before compiler options so options don't goof up finding
# === OpenMP
# optional, for possible MUMPS speedup
if(openmp)
find_package(OpenMP COMPONENTS C Fortran)
endif()
# === MPI
# MPI is used throughout Gemini
find_package(MPI REQUIRED COMPONENTS Fortran)
# sometimes a mismatch exists between CMake's found MPI and the compiler.
# Catch this here to avoid confusing build errors.
# Runtime errors will be caught by test_mpi in ctest.
set(CMAKE_REQUIRED_INCLUDES ${MPI_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES MPI::MPI_Fortran)
check_fortran_source_compiles("use mpi; end" MPI_OK SRC_EXT f90)
if(NOT MPI_OK)
message(FATAL_ERROR "${MPI_Fortran_LIBRARIES} not working with ${CMAKE_Fortran_COMPILER_ID} ${CMAKE_Fortran_COMPILER_VERSION}")
endif()