# The findMPI in Cmake 3.18 can not find MSMPI for Fortran

**URL:** https://discourse.cmake.org/t/the-findmpi-in-cmake-3-18-can-not-find-msmpi-for-fortran/1791
**Category:** Usage
**Created:** [September 7, 2020, 10:56pm UTC](https://discourse.cmake.org/t/the-findmpi-in-cmake-3-18-can-not-find-msmpi-for-fortran/1791 "2020-09-07T22:56:47Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![tmishima](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/da6949/32.png) [@tmishima](https://discourse.cmake.org/u/tmishima)
#### Post date: [September 7, 2020, 10:56pm UTC](https://discourse.cmake.org/t/the-findmpi-in-cmake-3-18-can-not-find-msmpi-for-fortran/1791/1 "2020-09-07T22:56:47Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [November 15, 2020, 2:53pm UTC](https://discourse.cmake.org/t/the-findmpi-in-cmake-3-18-can-not-find-msmpi-for-fortran/1791/2 "2020-11-15T14:53:34Z")

</div>

I was not aware that MSMPI included Fortran support.

Cc: @chuckatkins

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [January 4, 2021, 3:26pm UTC](https://discourse.cmake.org/t/the-findmpi-in-cmake-3-18-can-not-find-msmpi-for-fortran/1791/3 "2021-01-04T15:26:19Z")

</div>

FWIW, it seems that support does exist and it is attempted. Some investigations will be needed. I’ve reported [an issue](https://gitlab.kitware.com/cmake/cmake/-/issues/21655) to track this.
