2 # This file is used by EnableLanguage in cmGlobalGenerator to
3 # determine that that selected Fortran compiler can actually compile
4 # and link the most basic of programs. If not, a fatal error
5 # is set and cmake stops processing commands and will not generate
6 # any makefiles or projects.
7 IF(NOT CMAKE_Fortran_COMPILER_WORKS)
8 MESSAGE(STATUS "Check for working Fortran compiler: ${CMAKE_Fortran_COMPILER}")
9 FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f "
14 TRY_COMPILE(CMAKE_Fortran_COMPILER_WORKS ${CMAKE_BINARY_DIR}
15 ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f
16 OUTPUT_VARIABLE OUTPUT)
17 SET(FORTRAN_TEST_WAS_RUN 1)
18 ENDIF(NOT CMAKE_Fortran_COMPILER_WORKS)
20 IF(NOT CMAKE_Fortran_COMPILER_WORKS)
21 MESSAGE(STATUS "Check for working Fortran compiler: ${CMAKE_Fortran_COMPILER} -- broken")
22 FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
23 "Determining if the Fortran compiler works failed with "
24 "the following output:\n${OUTPUT}\n\n")
25 MESSAGE(FATAL_ERROR "The Fortran compiler \"${CMAKE_Fortran_COMPILER}\" "
26 "is not able to compile a simple test program.\nIt fails "
27 "with the following output:\n ${OUTPUT}\n\n"
28 "CMake will not be able to correctly generate this project.")
29 ELSE(NOT CMAKE_Fortran_COMPILER_WORKS)
30 IF(FORTRAN_TEST_WAS_RUN)
31 MESSAGE(STATUS "Check for working Fortran compiler: ${CMAKE_Fortran_COMPILER} -- works")
32 FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
33 "Determining if the Fortran compiler works passed with "
34 "the following output:\n${OUTPUT}\n\n")
35 ENDIF(FORTRAN_TEST_WAS_RUN)
36 SET(CMAKE_Fortran_COMPILER_WORKS 1 CACHE INTERNAL "")
37 ENDIF(NOT CMAKE_Fortran_COMPILER_WORKS)
39 IF(CMAKE_Fortran_COMPILER_WORKS)
40 # Test for Fortran 90 support by using an f90-specific construct.
41 IF(NOT DEFINED CMAKE_Fortran_COMPILER_SUPPORTS_F90)
42 MESSAGE(STATUS "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90")
43 FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90 "
45 stop = 1 ; do while ( stop .eq. 0 ) ; end do
46 END PROGRAM TESTFortran90
48 TRY_COMPILE(CMAKE_Fortran_COMPILER_SUPPORTS_F90 ${CMAKE_BINARY_DIR}
49 ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90
50 OUTPUT_VARIABLE OUTPUT)
51 IF(CMAKE_Fortran_COMPILER_SUPPORTS_F90)
52 MESSAGE(STATUS "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90 -- yes")
53 FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
54 "Determining if the Fortran compiler supports Fortran 90 passed with "
55 "the following output:\n${OUTPUT}\n\n")
56 SET(CMAKE_Fortran_COMPILER_SUPPORTS_F90 1 CACHE INTERNAL "")
57 ELSE(CMAKE_Fortran_COMPILER_SUPPORTS_F90)
58 MESSAGE(STATUS "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90 -- no")
59 FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
60 "Determining if the Fortran compiler supports Fortran 90 failed with "
61 "the following output:\n${OUTPUT}\n\n")
62 SET(CMAKE_Fortran_COMPILER_SUPPORTS_F90 0 CACHE INTERNAL "")
63 ENDIF(CMAKE_Fortran_COMPILER_SUPPORTS_F90)
64 ENDIF(NOT DEFINED CMAKE_Fortran_COMPILER_SUPPORTS_F90)
65 ENDIF(CMAKE_Fortran_COMPILER_WORKS)