这里有一个简单的问题,我需要在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.
我可以在这里追踪更多信息吗?非常感谢。
帮助他人:4年后,我遇到了同样的问题。我通过确保您指向CMakeList.txt
中FORTRAN可执行文件的确切位置来解决它,如下所示:set(CMAKE_Fortran_COMPILER "C:/MinGW/bin/gfortran.exe")
。这为我解决了问题。让我知道它是否有效。
因为Visual Studio生成器不支持MinGW gfortran。它们是完全独立的生态系统。删除您的构建目录并创建一个新目录。
因此,要定义生成器,对我来说有效的是使用命令行中的标志来定义它
cmake -G "MinGW Makefiles"
我还尝试将CMAKE_GENERATOR设置为CMakefile.txt 中的变量
set(CMAKE_GENERATOR "MinGW Makefiles")
但由于某种原因,它不起作用,我不得不在命令行