Description
This is not a stdlib-specific problem, but others may encounter the same obstacle. When I try to build stdlib using cmake on Windows, I get the following problem. How do I tell cmake to use gfortran and specify its location? I see discussion of this problem here but don't see a resolution.
c:\fortran\public_domain\github\stdlib_20210302>gfortran --version
GNU Fortran (GCC) 11.0.0 20200927 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
c:\fortran\public_domain\github\stdlib_20210302>cmake -B build
-- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.21322.
-- The Fortran compiler identification is unknown
CMake Error at CMakeLists.txt:2 (project):
No CMAKE_Fortran_COMPILER could be found.
-- Configuring incomplete, errors occurred!
See also "C:/fortran/public_domain/github/stdlib_20210302/build/CMakeFiles/CMakeOutput.log".
See also "C:/fortran/public_domain/github/stdlib_20210302/build/CMakeFiles/CMakeError.log".
Activity
leonfoks commentedon Mar 2, 2021
I think add -DCMAKE_Fortran_COMPILER=<path-to-gfortran> to the cmake command
Beliavsky commentedon Mar 2, 2021
Thanks @leonfoks . Even when I tell cmake to use gfortran, it tries to use Intel Fortran within Visual Studio for some reason:
c:\fortran\public_domain\github\stdlib_20210302>cmake -B build -DCMAKE_Fortran_COMPILER=c:/equation/bin
-- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.21322.
-- The Fortran compiler identification is unknown
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - failed
-- Check for working Fortran compiler: c:/equation/bin
-- Check for working Fortran compiler: c:/equation/bin - broken
CMake Error at C:/Users/myname/AppData/Roaming/Python/Python36/site-packages/cmake/data/share/cmake-3.18/Modules/CMakeTestFortranCompiler.cmake:51 (message):
The Fortran compiler
is not able to compile a simple test program.
It fails with the following output:
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "C:/fortran/public_domain/github/stdlib_20210302/build/CMakeFiles/CMakeOutput.log".
See also "C:/fortran/public_domain/github/stdlib_20210302/build/CMakeFiles/CMakeError.log".
leonfoks commentedon Mar 2, 2021
I should have said specify the full path to gfortran, not just the path to the containing folder, so add gfortran to the end.
cmake -B build -DCMAKE_Fortran_COMPILER=c:/equation/bin/gfortran
Beliavsky commentedon Mar 2, 2021
Thanks, but that's not the problem. The gfortran binary is at c:\equation\bin\gfortran.exe .
leonfoks commentedon Mar 2, 2021
Yes I see, I get the same thing. Personally i've installed MinGW and then use cmake -G "MinGW Makefiles" and it detects fine.
I did not see the subtle difference between what you tried and what i'm used to, so apologies for that! I tried to get it working without assuming a MinGW install but no dice yet and I get the message you posted.