Using ifx rather than ifort with cmake

I’ll leave this here as a note-to-self and for anyone else bumping into the same rock:

In order to build a MVS2022 project that can switch between classic or LLVM compilers (assuming <= oneAPI2023), one can now do it with CMake (version >3.29, I’m testing with 3.30.2):

  • Classic C++ and Classic Fortran
    -DCMAKE_GENERATOR_TOOLSET=Intel C++ Compiler 19.2,fortran=ifort
  • LLVM C++ and LLVM Fortran
    -DCMAKE_GENERATOR_TOOLSET=Intel C++ Compiler 2023,fortran=ifx

The Visual project is well set, and one can also then manually revert/change the compiler for individual projects.

1 Like