[cmake-developers] [PATCH] Fix CMAKE_Fortran_PLATFORM_ID on mingw-w64

Ben Boeckel ben.boeckel at kitware.com
Mon Apr 4 10:33:59 EDT 2016


On Mon, Apr 04, 2016 at 09:07:09 +0000, Melven.Roehrig-Zoellner at dlr.de wrote:
> After thinking about my patch I worried it could break other compilers.
> So, here is a more defensive version that shouldn't interfere with anything else.
> 
> Explanation:
> CMAKE_Fortran_COMPILER_ID was correctly set to "GNU";
> If CMAKE_Fortran_PLATFORM_IS is missing, run gfortran with a C file
> -> fallback to C which has appropriate preprocessor definitions to recognize MINGW.

+    exec_program(${CMAKE_Fortran_COMPILER}
+      ARGS ${CMAKE_Fortran_COMPILER_ID_FLAGS_LIST} -E
+"\"${CMAKE_ROOT}/Modules/CMakeTestGNU.c\""
+      OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT RETURN_VALUE
+CMAKE_COMPILER_RETURN)

Please use `execute_process` instead.

+    if(NOT CMAKE_COMPILER_RETURN)
+      if(NOT CMAKE_Fortran_PLATFORM_ID)

Is this not always true inside this block?

+        if("${CMAKE_COMPILER_OUTPUT}" MATCHES "THIS_IS_MINGW")

Use:

    if (CMAKE_COMPILER_OUTPUT MATCHES "THIS_IS_MINGW")

+          set(CMAKE_Fortran_PLATFORM_ID "MinGW")
+        endif()
+        if("${CMAKE_COMPILER_OUTPUT}" MATCHES "THIS_IS_CYGWIN")

elseif? Similar transformation as above.

+          set(CMAKE_Fortran_PLATFORM_ID "Cygwin")
+        endif()
+      endif()
+    endif()

--Ben


More information about the cmake-developers mailing list