How to use oneAPI Fortran ifx on WIndows Visual Studio generator?

CMake 3.29 is to have enabled oneAPI ifx with Visual Studio generator on Windows. I use oneAPI Fortran on Windows all the time with Ninja successfully, but have not figured out how to do so with Visual Studio generator.

How is the Intel oneAPI Fortran compiler used with Visual Studio generator? I tried invoking from the oneAPI command prompt (which works with Ninja generator) using CMake 3.29-0-rc4 (and nightly) like:

cmake -Bbuildi -G "Visual Studio 17 2022" -DCMAKE_GENERATOR_TOOLSET="fortran=ifx" -DCMAKE_Fortran_COMPILER="C:/Program Files (x86)/Intel/oneAPI/compiler/2024.0/bin/ifx.exe"

but the Fortran compiler was NOTFOUND or unknown.

So I agree that information on how to use IFX with VS/CMake is not very clear. Here’s what I just tried and seems to work.
Using your example:
cmake -Bbuildi -G “Visual Studio 17 2022” -T “fortran=ifx”

With that it switches to use the LLVM compiler and when I open the solution in VS, any Fortran project now indicates IFX instead of IFORT.

thanks – however I get the same result with -T "fortran=ifx" as before. This is from oneAPI command prompt with CMake 3.29.0 and Intel oneAPI 2024.0

cmake -Bbuildi -G "Visual Studio 17 2022" -T "fortran=ifx"
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.22631.
-- The C compiler identification is MSVC 19.39.33522.0
-- The Fortran compiler identification is unknown
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
CMake Error at CMakeLists.txt:3 (project):
  No CMAKE_Fortran_COMPILER could be found.
1 Like

Have you tried this using the CMake UI? It may be easier to troubleshoot there. I’ve not tried using the OneAPI command prompt.

Also what is at line 3 in CMakeLists?
Try putting:
enable_language(Fortran CXX)
above that.

Did you manage to resolve the issue? I am currently facing the same

Not sure if scivision resolved their issue, but here is updated info on my setup.
One of the challenges was CMake and Microsoft lagging behind Intel on IFX support but that should be behind us. In my case, the project uses Fortran and C/C++

Here are the current component versions:
Intel OneAPI 2025.1 (Basekit & HPCkit)
CMake 4.0
Visual Studio 2022 LTSC 17.8

Here are snippets of my CMakeLists and a Windows batch file I use.
CMakeLists (First statements)

message(STATUS "CMake version: ${CMAKE_VERSION}")

if (CMAKE_HOST_WIN32)
# need CMake 3.25.0+ for IntelLLVM support of target link properties on Windows
cmake_minimum_required(VERSION 3.31)
else()
# CMake 3.23.5 is the minimum recommended for IntelLLVM on Linux
cmake_minimum_required(VERSION 3.23.5)
endif()

IF (WIN32)
cmake_policy(SET CMP0091 NEW)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded")
endif()

project ("<Project Name>" Fortran CXX)

Windows Batch (Started from location of CMakeLists.txt)

echo Deleting old cache...
del /Q CMakeCache.txt >nul 2>&1
del /S /Q CMakeFiles >nul 2>&1
echo Making 64-bit Visual Studio project ...
"C:\Program Files\CMake\bin\cmake" -G "Visual Studio 17 2022" -T "fortran=ifx" -A x64 .

Here is the output to the console:

Deleting old cache...
Making 64-bit Visual Studio project ...
-- CMake version: 4.0.0
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.22631.
-- The Fortran compiler identification is IntelLLVM 2025.1.0 with MSVC-like command-line
-- The CXX compiler identification is MSVC 19.38.33145.0
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Determine Intel Fortran Compiler Implicit Link Path
-- Determine Intel Fortran Compiler Implicit Link Path - done
-- Check for working Fortran compiler: C:/Program Files (x86)/Intel/oneAPI/compiler/2025.1/bin/ifx.exe - skipped
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Fortran Compiler ID: IntelLLVM
-- CXX Compiler ID: MSVC
-- The C compiler identification is MSVC 19.38.33145.0

So the output from below the “CMake version” line down to above the “Fortran Compiler ID:” line is related to the “project …” line in CMakeLists.txt.
If I recall correctly, one key was declaring the language on the project line as shown above.

I hope this helps.