Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29064 Discussions

Seeting up CMake with oneAPI23+MVS2022 to switch between classic and LLVM compilers (Fortran/C++)

hkvzjal
New Contributor I
597 Views

Hi,

 

I'm trying to upgrade my build system to enable building MVS2022 projects in which I can switch between classic and LLVM compilers but I am hitting an issue with CMake

dev stack version:

oneAPI2023 + MVS2022 + CMake 3.30.2

 

(I'm working with oneAPI23 because it is the last to offer both version for the C++ compilers which I need to validate before moving to LLVM)

 

I have a python script that enables me to setup the whole building process (large project) where, to change between classic C++ and LLVM I would setup something like:

```python

if cpp_compiler_param == "icl23" and build_environment == "vs2022":
      args_cmake_call.append("-DCMAKE_GENERATOR_TOOLSET=Intel C++ Compiler 19.2")

if cpp_compiler_param == "icx23" and build_environment == "vs2022":
      args_cmake_call.append("-DCMAKE_GENERATOR_TOOLSET=Intel C++ Compiler 2023")

```

For Fortran I had no need to do anything before since there was just one compiler. Now, since CMake 3.29 there is the `-T fortran=<compiler>` option to choose between ifort and ifx.

 

How can I simultaneously setup the generator toolset for C++ and Fortran to create different combinations? I haven't found a way to pass multiple fields to CMAKE_GENERATOR_TOOLSET in order to achive that. And if I try to append `-T fortran=<compiler>` after having setup the toolset for C++ CMake crashes saying there is a conflict.

 

Any hints? Thank you

0 Kudos
1 Solution
hkvzjal
New Contributor I
586 Views

Found the solution by trial and error ... using the "," to set the Fortran compiler was enough

"-DCMAKE_GENERATOR_TOOLSET=Intel C++ Compiler 2023,fortran=ifx"

Sorry and thanks,

It might be useful for other users

View solution in original post

1 Reply
hkvzjal
New Contributor I
587 Views

Found the solution by trial and error ... using the "," to set the Fortran compiler was enough

"-DCMAKE_GENERATOR_TOOLSET=Intel C++ Compiler 2023,fortran=ifx"

Sorry and thanks,

It might be useful for other users

Reply