No CMAKE_Fortran_COMPILER could be found.

I have been getting this error from my cmake-gui window when compiling my C++/Fortran based project.

The Fortran compiler identification is unknown CMake Error at Lib/Fast_Table/CMakeLists.txt:2 (project): No CMAKE_Fortran_COMPILER could be found.

I have looked all over the internet for possible solutions to my problem regarding the path and configuration between intel Fortran 2020, VS2017 and CMake 3.18.4.

Here is the CMakeError.log output:

Compiling the Fortran compiler identification source file "CMakeFortranCompilerId.F" failed.
Compiler:  
Build flags: 
Id flags:  

The output was:
1

Microsoft Visual Studio 2017 Version 15.0.28307.1525.
Copyright (C) Microsoft Corp. All rights reserved.

Package 'IFLangServicePackage' failed to load.

Package 'IFLangServicePackage' failed to load.

Package 'IFLangServicePackage' failed to load.

Package 'IFLangServicePackage' failed to load.

Package 'IFLangServicePackage' failed to load.
1>------ Build started: Project: CompilerIdFortran, Configuration: Debug x64 ------
1>Compiling with Intel(R) Visual Fortran Compiler 19.1.0.166 [Intel(R) 64]...
1>CMakeFortranCompilerId.F
1>Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.1.0.166 Build 20191121
1>Copyright (C) 1985-2019 Intel Corporation.  All rights reserved.
1>Linking...
1>Microsoft (R) Incremental Linker Version 14.16.27045.0
1>Copyright (C) Microsoft Corporation.  All rights reserved.
1>/OUT:.\CompilerIdFortran.exe
1>/INCREMENTAL:NO
1>/MANIFEST
1>/MANIFESTFILE:Debug\CompilerIdFortran.exe.intermediate.manifest
1>"/MANIFESTUAC:level='asInvoker' uiAccess='false'"
1>/DEBUG
1>/PDB:C:\tree2\CAE\_build\CNApps\CMakeFiles\3.18.4\CompilerIdFortran\CompilerIdFortran.pdb
1>/SUBSYSTEM:CONSOLE
1>/IMPLIB:C:\tree2\CAE\_build\CNApps\CMakeFiles\3.18.4\CompilerIdFortran\CompilerIdFortran.lib
1>Debug\CMakeFortranCompilerId.obj
1>LINK : fatal error LNK1104: cannot open file 'ifconsol.lib'
1>
1>Build log written to  "file://C:\tree2\CAE\_build\CNApps\CMakeFiles\3.18.4\CompilerIdFortran\Debug\BuildLog.htm"
1>CompilerIdFortran - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Compiling the Fortran compiler identification source file "CMakeFortranCompilerId.F" failed.
Compiler:  
Build flags: 
Id flags:  

The output was:
1

Microsoft Visual Studio 2017 Version 15.0.28307.1525.
Copyright (C) Microsoft Corp. All rights reserved.

Package 'IFLangServicePackage' failed to load.

Package 'IFLangServicePackage' failed to load.

Package 'IFLangServicePackage' failed to load.

Package 'IFLangServicePackage' failed to load.

Package 'IFLangServicePackage' failed to load.
1>------ Build started: Project: CompilerIdFortran, Configuration: Debug x64 ------
1>Compiling with Intel(R) Visual Fortran Compiler 19.1.0.166 [Intel(R) 64]...
1>CMakeFortranCompilerId.F
1>Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.1.0.166 Build 20191121
1>Copyright (C) 1985-2019 Intel Corporation.  All rights reserved.
1>Linking...
1>Microsoft (R) Incremental Linker Version 14.16.27045.0
1>Copyright (C) Microsoft Corporation.  All rights reserved.
1>/OUT:.\CompilerIdFortran.exe
1>/INCREMENTAL:NO
1>/MANIFEST
1>/MANIFESTFILE:Debug\CompilerIdFortran.exe.intermediate.manifest
1>"/MANIFESTUAC:level='asInvoker' uiAccess='false'"
1>/DEBUG
1>/PDB:C:\tree2\CAE\_build\CNApps\CMakeFiles\3.18.4\CompilerIdFortran\CompilerIdFortran.pdb
1>/SUBSYSTEM:CONSOLE
1>/IMPLIB:C:\tree2\CAE\_build\CNApps\CMakeFiles\3.18.4\CompilerIdFortran\CompilerIdFortran.lib
1>Debug\CMakeFortranCompilerId.obj
1>LINK : fatal error LNK1104: cannot open file 'ifconsol.lib'
1>
1>Build log written to  "file://C:\tree2\CAE\_build\CNApps\CMakeFiles\3.18.4\CompilerIdFortran\Debug\BuildLog.htm"
1>CompilerIdFortran - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Let me know if anything else is needed, thanks!

I use Intel Fortran on Windows with CMake regularly, previously with Parallel Studio and now with oneAPI (Classic and LLVM). I normally use the Start menu shortcut to the “Intel oneAPI command prompt for Visual Studio” – the 2019/2020 compiler you have also has such a command prompt shortcut in the Windows start menu.

1 Like

Turns out that my installations of VS2017 and Intel Fortran were not setting up correctly. I had to go to the Intel Fortran solution under the folder in my build directory under .\CMakeFiles\3.18.4\CompilerIdFortran. Then I opened the project in Visual Studio. Tools >> Options >> Intel Compilers and Tools >> Visual Fortran >> Compilers. Then I went to the x64 tab and instead of having “Latest” selected, I selected “Intel(R) Visual Fortran Compiler 19.1.0.166 [Intel(R) 64]” and this had the proper setup for compiling Fortran. There were also some files in the 2020 compilers_and_libraries dir that were not in the 2020.0.166 dir.

I hope that helps someone in the future if they have this specific error.