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.

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.