Browse Source

Pass Fortran90 test result to try-compile

This stores CMAKE_Fortran_COMPILER_SUPPORTS_F90 in the Fortran compiler
information file CMakeFiles/CMakeFortranCompiler.cmake instead of in
CMakeCache.txt.  This file makes the result available to try-compile
projects.
Brad King 16 năm trước cách đây
mục cha
commit
6843448379
2 tập tin đã thay đổi với 30 bổ sung28 xóa
  1. 2 0
      Modules/CMakeFortranCompiler.cmake.in
  2. 28 28
      Modules/CMakeTestFortranCompiler.cmake

+ 2 - 0
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)

+ 28 - 28
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)