在mingw32中使用CMake获取Fortran代码

时间:2015-12-09 17:41:14

标签: cmake fortran mingw32

这是一个简单的问题,我需要在mingw32上创建一个CMake构建器。我想在CMakeLists.txt中定义编译器(虽然我想在以后调用cmake时指定)。 txt文件如下所示:

cmake_minimum_required(VERSION 3.4)

SET(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_GENERATOR "MinGW Makefiles")
message("generator is set to ${CMAKE_GENERATOR}")

#set (CMAKE_Fortran_COMPILER "C:/Program Files/PGI/win64/15.10/bin")
set (CMAKE_Fortran_COMPILER "C:/Program Files (x86)/Silverfrost/FTN95")

然后它返回:

generator is set to MinGW Makefiles
-- The Fortran compiler identification is unknown
-- Check for working Fortran compiler: C:/Program Files     (x86)/Silverfrost/FTN95
-- Check for working Fortran compiler: C:/Program Files (x86)/Silverfrost/FTN95  -- broken
CMake Error at C:/Program Files (x86)/CMake/share/cmake-   3.4/Modules/CMakeTestFortranCompiler.cmake:54 (message):
The Fortran compiler "C:/Program Files (x86)/Silverfrost/FTN95" is not able
to compile a simple test program.

我做错了什么?我知道它没有正确找到编译器。谢谢你的帮助。

编辑。正如我所建议的那样,我发布了CMakeError.log

Compiling the Fortran compiler identification source file    "CMakeFortranCompilerId.F" failed.
Compiler: C:/Program Files (x86)/Silverfrost/FTN95 
Build flags: 
Id flags: -v

The output was:
Access is denied


Compiling the Fortran compiler identification source file    "CMakeFortranCompilerId.F" failed.
Compiler: C:/Program Files (x86)/Silverfrost/FTN95 
Build flags: 
Id flags: 

The output was:
Access is denied


Compiling the Fortran compiler identification source file  "CMakeFortranCompilerId.F" failed.
Compiler: C:/Program Files (x86)/Silverfrost/FTN95 
Build flags: 
Id flags: -c

The output was:
Access is denied


Compiling the Fortran compiler identification source file "CMakeFortranCompilerId.F" failed.
Compiler: C:/Program Files (x86)/Silverfrost/FTN95 
Build flags: 
Id flags: -fpp

 The output was:
 Access is denied


 Checking whether the Fortran compiler is Compaq using "-what" did not match   "Compaq Visual Fortran":
 Checking whether the Fortran compiler is NAG using "-V" did not match "NAG     Fortran Compiler":
 Determining if the Fortran compiler works failed with the following output:
 Change Dir:    C:/Users/RolandGuichard/Desktop/SATURN/SATGPU/testcm/CMakeFiles/CMakeTmp

 Run Build Command:"C:/Program Files (x86)/Microsoft Visual Studio    14.0/Common7/IDE/devenv.com" "CMAKE_TRY_COMPILE.sln" "/build" "Debug" "/project"   "cmTC_e9efb"
 The Application Data folder for Visual Studio could not be created.

我可以在这里追踪更多信息吗?谢谢。

2 个答案:

答案 0 :(得分:0)

帮助他人:4年后,我遇到了同样的问题。我通过确保像这样CMakeList.txt指向set(CMAKE_Fortran_COMPILER "C:/MinGW/bin/gfortran.exe")中FORTRAN可执行文件的确切位置来解决了该问题。这为我解决了。让我知道它是否有效。

答案 1 :(得分:0)

由于 Visual Studio 生成器不支持 MinGW gfortran。它们是完全独立的生态系统。删除您的构建目录并创建一个新目录。

所以定义生成器对我有用的是在命令行中使用一个标志来定义它

cmake -G "MinGW Makefiles"

我也尝试将 CMAKE_GENERATOR 设置为 CMakefile.txt 中的变量

set(CMAKE_GENERATOR "MinGW Makefiles")

但由于某种原因,它不起作用,我必须在命令行中传递生成器