Using ifx rather than ifort with cmake

If only it was that easy… While @runborg in the OP did not mentioned in the title, in the body of the post you can tell he is working under Windows + Microsoft Visual Studio 2022. Just as I have experienced myself, trying to migrate has proven extremely difficult…

Setting up just the environment variables can work if one uses Nmake to build and compile without the graphical editor. If one wants to build, compile and debug natively with MVS2022, then it is necessary to also setup the toolset in CMake such that the project recognizes the compiler. Problem is: the option has been barely added recently, if you are a solo developer, go ahead and install CMake 3.30.1, but if you are working in a large team and have a CI already in place, chances are you cannot “just” upgrade.

I would also like to know if there is a work-around to enable CMake (<3.29) to tell Visual that it should use ifx instead of ifort. So far, I haven’t found anything, the only solution seems to be to go manually through every single Fortran project after the MVS Solution is opened and within the complete solution, for each individual project “Right click on Fortran project name>Intel Compiler>Intel IFX …”.