diff --git a/Modules/CMakeFortranCompiler.cmake.in b/Modules/CMakeFortranCompiler.cmake.in index afd9ce0fd..d8a9ed6cd 100644 --- a/Modules/CMakeFortranCompiler.cmake.in +++ b/Modules/CMakeFortranCompiler.cmake.in @@ -15,6 +15,8 @@ ENDIF(CMAKE_COMPILER_IS_CYGWIN) SET(CMAKE_Fortran_COMPILER_ENV_VAR "FC") +SET(CMAKE_Fortran_COMPILER_SUPPORTS_F90 @CMAKE_Fortran_COMPILER_SUPPORTS_F90@) + IF(CMAKE_COMPILER_IS_MINGW) SET(MINGW 1) ENDIF(CMAKE_COMPILER_IS_MINGW) diff --git a/Modules/CMakeTestFortranCompiler.cmake b/Modules/CMakeTestFortranCompiler.cmake index 6591c2dff..cb91572c0 100644 --- a/Modules/CMakeTestFortranCompiler.cmake +++ b/Modules/CMakeTestFortranCompiler.cmake @@ -42,6 +42,34 @@ ELSE(NOT CMAKE_Fortran_COMPILER_WORKS) # Try to identify the ABI and configure it into CMakeFortranCompiler.cmake INCLUDE(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) CMAKE_DETERMINE_COMPILER_ABI(Fortran ${CMAKE_ROOT}/Modules/CMakeFortranCompilerABI.F) + + # Test for Fortran 90 support by using an f90-specific construct. + IF(NOT DEFINED CMAKE_Fortran_COMPILER_SUPPORTS_F90) + MESSAGE(STATUS "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90") + FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90 " + PROGRAM TESTFortran90 + stop = 1 ; do while ( stop .eq. 0 ) ; end do + END PROGRAM TESTFortran90 +") + TRY_COMPILE(CMAKE_Fortran_COMPILER_SUPPORTS_F90 ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90 + OUTPUT_VARIABLE OUTPUT) + IF(CMAKE_Fortran_COMPILER_SUPPORTS_F90) + MESSAGE(STATUS "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90 -- yes") + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the Fortran compiler supports Fortran 90 passed with " + "the following output:\n${OUTPUT}\n\n") + SET(CMAKE_Fortran_COMPILER_SUPPORTS_F90 1) + ELSE(CMAKE_Fortran_COMPILER_SUPPORTS_F90) + MESSAGE(STATUS "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90 -- no") + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the Fortran compiler supports Fortran 90 failed with " + "the following output:\n${OUTPUT}\n\n") + SET(CMAKE_Fortran_COMPILER_SUPPORTS_F90 0) + ENDIF(CMAKE_Fortran_COMPILER_SUPPORTS_F90) + UNSET(CMAKE_Fortran_COMPILER_SUPPORTS_F90 CACHE) + ENDIF(NOT DEFINED CMAKE_Fortran_COMPILER_SUPPORTS_F90) + CONFIGURE_FILE( ${CMAKE_ROOT}/Modules/CMakeFortranCompiler.cmake.in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeFortranCompiler.cmake @@ -49,31 +77,3 @@ ELSE(NOT CMAKE_Fortran_COMPILER_WORKS) ) ENDIF(CMAKE_Fortran_COMPILER_FORCED) ENDIF(NOT CMAKE_Fortran_COMPILER_WORKS) - -IF(CMAKE_Fortran_COMPILER_WORKS) - # Test for Fortran 90 support by using an f90-specific construct. - IF(NOT DEFINED CMAKE_Fortran_COMPILER_SUPPORTS_F90) - MESSAGE(STATUS "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90") - FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90 " - PROGRAM TESTFortran90 - stop = 1 ; do while ( stop .eq. 0 ) ; end do - END PROGRAM TESTFortran90 - ") - TRY_COMPILE(CMAKE_Fortran_COMPILER_SUPPORTS_F90 ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90 - OUTPUT_VARIABLE OUTPUT) - IF(CMAKE_Fortran_COMPILER_SUPPORTS_F90) - MESSAGE(STATUS "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90 -- yes") - FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the Fortran compiler supports Fortran 90 passed with " - "the following output:\n${OUTPUT}\n\n") - SET(CMAKE_Fortran_COMPILER_SUPPORTS_F90 1 CACHE INTERNAL "") - ELSE(CMAKE_Fortran_COMPILER_SUPPORTS_F90) - MESSAGE(STATUS "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90 -- no") - FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if the Fortran compiler supports Fortran 90 failed with " - "the following output:\n${OUTPUT}\n\n") - SET(CMAKE_Fortran_COMPILER_SUPPORTS_F90 0 CACHE INTERNAL "") - ENDIF(CMAKE_Fortran_COMPILER_SUPPORTS_F90) - ENDIF(NOT DEFINED CMAKE_Fortran_COMPILER_SUPPORTS_F90) -ENDIF(CMAKE_Fortran_COMPILER_WORKS)