The findMPI in Cmake 3.18 can not find MSMPI for Fortran

Hi folks,

The findMPI in Cmake 3.18 cannot find MSMPI for Fortran, which set MPI_Fortran_WORKS=False.

On the other hand, the findMPI in Cmake 3.16.2 does find MSMPI successfully.

A workaround so far is:

if(WIN32 AND DEFINED ENV{MSMPI_INC}) # workaround for findMPI in cmake 3.18

string(REPLACE \ / MSMPI $ENV{MSMPI_INC})

set(MPI_Fortran_ADDITIONAL_INCLUDE_DIRS “${MSMPI};${MSMPI}x64/”)

set(MPI_GUESS_LIBRARY_NAME “MSMPI”)

endif()

find_package (MPI)

Then it works well for my application.

I guess the search process, especially step 1 of Cmake 3.18, affects the result:

Cmake 3.16.2:

  1. Check if the compiler has MPI support built-in. This is the case if the user passed a

compiler wrapper as CMAKE_<LANG>_COMPILER or if they’re on a Cray system.

  1. Attempt to find an MPI compiler wrapper and determine the compiler information from it.

  2. Try to find an MPI implementation that does not ship such a wrapper by guessing settings.

Currently, only Microsoft MPI and MPICH2 on Windows are supported.

Cmake 3.18:

  1. Search for MPIEXEC_EXECUTABLE and, if found, use its base directory.

  2. Check if the compiler has MPI support built-in. This is the case if the user passed a

compiler wrapper as CMAKE_<LANG>_COMPILER or if they’re on a Cray system.

  1. Attempt to find an MPI compiler wrapper and determine the compiler information from it.

  2. Try to find an MPI implementation that does not ship such a wrapper by guessing settings.

Currently, only Microsoft MPI and MPICH2 on Windows are supported.

Regards.

Tetsuya Mishima

I was not aware that MSMPI included Fortran support.

Cc: @chuckatkins