summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeDetermineFortranCompiler.cmake
diff options
context:
space:
mode:
authorMelven Roehrig-Zoellner <Melven.Roehrig-Zoellner@DLR.de>2016-04-03 21:01:22 (GMT)
committerBrad King <brad.king@kitware.com>2016-04-05 13:50:14 (GMT)
commit8c4f100a56619bf115115d0bcaa322c422f0c44f (patch)
tree23e3cc96cc0b5eef082526c88c7670915939e966 /Modules/CMakeDetermineFortranCompiler.cmake
parent66fa61439db3043e903074a526aa2200e9766dcc (diff)
downloadCMake-8c4f100a56619bf115115d0bcaa322c422f0c44f.zip
CMake-8c4f100a56619bf115115d0bcaa322c422f0c44f.tar.gz
CMake-8c4f100a56619bf115115d0bcaa322c422f0c44f.tar.bz2
Fortran: Fix platform id detection on mingw-w64
On mingw-w64 the GNU Fortran compiler does not define `__MINGW32__` or any similar indicator. Fix `CMAKE_Fortran_PLATFORM_ID` detection in this case by falling back to preprocessing a `.c` source file even when the compiler id is already detected.
Diffstat (limited to 'Modules/CMakeDetermineFortranCompiler.cmake')
-rw-r--r--Modules/CMakeDetermineFortranCompiler.cmake15
1 files changed, 15 insertions, 0 deletions
diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake
index 1baca29..4f2a70c 100644
--- a/Modules/CMakeDetermineFortranCompiler.cmake
+++ b/Modules/CMakeDetermineFortranCompiler.cmake
@@ -209,6 +209,21 @@ if(NOT CMAKE_Fortran_COMPILER_ID_RUN)
endif()
endif()
+ # Fall back for GNU MINGW, which is not always detected correctly
+ # (__MINGW32__ is defined for the C language, but perhaps not for Fortran!)
+ if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU" AND NOT CMAKE_Fortran_PLATFORM_ID)
+ execute_process(COMMAND ${CMAKE_Fortran_COMPILER} ${CMAKE_Fortran_COMPILER_ID_FLAGS_LIST} -E "${CMAKE_ROOT}/Modules/CMakeTestGNU.c"
+ OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT RESULT_VARIABLE CMAKE_COMPILER_RETURN)
+ if(NOT CMAKE_COMPILER_RETURN)
+ if(CMAKE_COMPILER_OUTPUT MATCHES "THIS_IS_MINGW")
+ set(CMAKE_Fortran_PLATFORM_ID "MinGW")
+ endif()
+ if(CMAKE_COMPILER_OUTPUT MATCHES "THIS_IS_CYGWIN")
+ set(CMAKE_Fortran_PLATFORM_ID "Cygwin")
+ endif()
+ endif()
+ endif()
+
# Set old compiler and platform id variables.
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
set(CMAKE_COMPILER_IS_GNUG77 1)