【问题标题】:Using CMake in mingw32 for a Fortran code在 mingw32 中使用 CMake 获取 Fortran 代码
【发布时间】:2016-03-15 02:48:26
【问题描述】:

这是一个简单的问题,我需要在 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.

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

【问题讨论】:

  • 必须有一些更完整的日志文件包含实际的编译错误。
  • 是的,会有帮助吗?
  • 谁知道呢,没看到。您绝对应该发布它。
  • 检查您的构建目录中的 CMakeFiles/CMakeError.log。

标签: cmake fortran mingw32


【解决方案1】:

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

【讨论】:

    【解决方案2】:

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

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

    cmake -G "MinGW Makefiles"
    

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

    set(CMAKE_GENERATOR "MinGW Makefiles")
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-19
      • 1970-01-01
      相关资源
      最近更新 更多