浏览代码

Provide macro to force Fortran compiler

We add the macro CMAKE_FORCE_Fortran_COMPILER to the cross-compiling
helper module CMakeForceCompiler.cmake so that toolchain files can force
a Fortran compiler as well as C and C++ compilers.  See issue #10032.
Brad King 16 年之前
父节点
当前提交
126c93cdda
共有 1 个文件被更改,包括 20 次插入0 次删除
  1. 20 0
      Modules/CMakeForceCompiler.cmake

+ 20 - 0
Modules/CMakeForceCompiler.cmake

@@ -16,6 +16,13 @@
 # It also bypasses the check for working compiler and basic compiler
 # It also bypasses the check for working compiler and basic compiler
 # information tests.
 # information tests.
 #
 #
+# Macro CMAKE_FORCE_Fortran_COMPILER has the following signature:
+#   CMAKE_FORCE_Fortran_COMPILER(<compiler> <compiler-id>)
+# It sets CMAKE_Fortran_COMPILER to the given compiler and the cmake
+# internal variable CMAKE_Fortran_COMPILER_ID to the given compiler-id.
+# It also bypasses the check for working compiler and basic compiler
+# information tests.
+#
 # So a simple toolchain file could look like this:
 # So a simple toolchain file could look like this:
 #   INCLUDE (CMakeForceCompiler)
 #   INCLUDE (CMakeForceCompiler)
 #   SET(CMAKE_SYSTEM_NAME Generic)
 #   SET(CMAKE_SYSTEM_NAME Generic)
@@ -60,3 +67,16 @@ MACRO(CMAKE_FORCE_CXX_COMPILER compiler id)
     SET(CMAKE_COMPILER_IS_GNUCXX 1)
     SET(CMAKE_COMPILER_IS_GNUCXX 1)
   ENDIF("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
   ENDIF("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
 ENDMACRO(CMAKE_FORCE_CXX_COMPILER)
 ENDMACRO(CMAKE_FORCE_CXX_COMPILER)
+
+MACRO(CMAKE_FORCE_Fortran_COMPILER compiler id)
+  SET(CMAKE_Fortran_COMPILER "${compiler}")
+  SET(CMAKE_Fortran_COMPILER_ID_RUN TRUE)
+  SET(CMAKE_Fortran_COMPILER_ID ${id})
+  SET(CMAKE_Fortran_COMPILER_WORKS TRUE)
+  SET(CMAKE_Fortran_COMPILER_FORCED TRUE)
+
+  # Set old compiler id variables.
+  IF("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU")
+    SET(CMAKE_COMPILER_IS_GNUG77 1)
+  ENDIF("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU")
+ENDMACRO(CMAKE_FORCE_Fortran_COMPILER)