How to use Intel MPI library with cmake on Windows (VS2017)?

I have a mixed language MPI package that uses cmake on linux. While on Windows, I am using Visual Studio 2017. The C/C++ compiler will be the Microsoft cl, and Fortran compiler will be the Intel ifort 2017 (hosted in VS 2017). I know Microsoft has MPI msi, and Intel has its own MPI Library, is it possible to make it work with cmake?

Here is what I did, but cmake does not recognize either C or Fortran MPI component:

  1. Within VS2017, I select the ifort 2019.1.3.311 as Intel fortran compiler
  2. The Intel MPI library is installed in C:\Program Files (x86)\IntelSWTools\mpi\2019.10.321\intel64
  3. I set MPI_HOME to above installed location, and launch cmake-gui.exe

Here is the error:
Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.19043.

The C compiler identification is MSVC 19.16.27034.0

The Fortran compiler identification is Intel 19.1.3.20201010

Detecting C compiler ABI info

Detecting C compiler ABI info - done

Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe - skipped

Detecting C compile features

Detecting C compile features - done

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)/IntelSWTools/compilers_and_libraries_2020.4.311/windows/bin/intel64/ifort.exe - skipped

Could NOT find MPI_C (missing: MPI_C_WORKS)

Could NOT find MPI_Fortran (missing: MPI_Fortran_WORKS)

CMake Error at C:/Program Files/CMake/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find MPI (missing: MPI_C_FOUND MPI_Fortran_FOUND C Fortran)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.23/Modules/FindMPI.cmake:1830 (find_package_handle_standard_args)
CMakeLists.txt:21 (find_package)

Configuring incomplete, errors occurred!

Obviously, I am missing something, right?

Actually, with Intel MPI library, if I load the var first:
C:\Users\allen\Desktop\mumps-main>“C:\Program Files (x86)\IntelSWTools\mpi\2019.10.321\intel64\bin\mpivars.bat”

Intel(R) MPI Library 2019 Update 10 for Windows* Target Build Environment for Intel(R) 64 applications
Copyright 2007-2021 Intel Corporation.

C:\Users\allen\Desktop\mumps-fetchcontent-main>cmake . -G “Visual Studio 15 2017 Win64”
– Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.19043.
– The C compiler identification is MSVC 19.16.27034.0
– The Fortran compiler identification is Intel 19.1.3.20201010
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe - skipped
– Detecting C compile features
– Detecting C compile features - done
– 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)/IntelSWTools/compilers_and_libraries_2020.4.311/windows/bin/intel64/ifort.exe - skipped
– Found MPI_C: C:/Program Files (x86)/IntelSWTools/mpi/2019.10.321/intel64/lib/release/impi.lib (found version “3.1”)
– Found MPI_Fortran: C:/Program Files (x86)/IntelSWTools/mpi/2019.10.321/intel64/lib/release/impi.lib (found version “3.1”)
– Found MPI: TRUE (found version “3.1”) found components: C Fortran
– checking that C and Fortran compilers can link
– checking that C and Fortran compilers can link - OK

Then both C and Fortran MPI will be ok, but it is just that this MPI_C is using Intel’s C compiler, not the Microsoft C compiler. (Our site does not use Intel C compiler, except me). Any pointer to de-commision the intel C?

Where do you see this? It looks to me like C code will use MSVC in the output you provided. Are you referring to detection? If so, I don’t think that affects the actual builds.

I interpret this result as MSVC using the Intel MPI library for the C language. I am the author of the MUMPS CMake scripts you’re using. Because the numerical core of MUMPS is written in Fortran, building MUMPS requires an ABI-compatible Fortran compiler (that check is written by me) even if your project is primarily in C.