# FindMPI insists on Fortran

**URL:** https://discourse.cmake.org/t/findmpi-insists-on-fortran/3922
**Category:** Code
**Tags:** os:linux
**Created:** [August 12, 2021, 7:47pm UTC](https://discourse.cmake.org/t/findmpi-insists-on-fortran/3922 "2021-08-12T19:47:28Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jsuthe](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jsuthe/32/1656_2.png) [@jsuthe](https://discourse.cmake.org/u/jsuthe)
#### Post date: [August 12, 2021, 7:47pm UTC](https://discourse.cmake.org/t/findmpi-insists-on-fortran/3922/1 "2021-08-12T19:47:28Z")

</div>

I’m getting failures when finding MPI:

> ```
> Could NOT find MPI (missing: MPI_CXX_FOUND CXX)
> Reason given by package: MPI component 'Fortran' was requested, but language Fortran is not enabled.
> 
> ```

My CMake code:

```auto
  find_package( MPI REQUIRED COMPONENTS CXX )

```

I’m not compiling any fortran, although there are some fortran files in my project that are conditionally compiled.

The MPI installation is found (`MPI_CXX_COMPILER` and other `MPI_CXX_*` cache variables are populated). I’ve tried setting things like `MPIEXEC_EXECUTABLE`, `MPI_HOME`, etc. with no effect.

System information:

- CMake version 3.18.12 on Linux
- openmpi version 4.0.4

**Other things I’ve tried:**

- CMake versions 3.13.3 and 3.15.3, which fail with:

- On OSX, there is no problem.

- An `mpich` installation doesn’t appear to manifest this problem.

I’ve seen some discussion [here](https://gitlab.kitware.com/cmake/cmake/-/issues/21491), but there wasn’t an apparent resolution.

Any tips on how to troubleshoot this? I’m suspecting a potential problem with the `openmpi` installation, but `CMake` isn’t helping here…

---

<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: [August 12, 2021, 7:50pm UTC](https://discourse.cmake.org/t/findmpi-insists-on-fortran/3922/2 "2021-08-12T19:50:49Z")

</div>

I think this was a problem with the crafting of the message rather than actually caring about Fortran support. The `missing: MPI_CXX_FOUND CXX` is the more important part here. Some logic is probably considering the `MPI_CXX_` variable you have not enough. Debugging can be done with `--debug-find` and `--trace-expand` flags to CMake to see why the `MPI_CXX_FOUND` ends up being false (or what condition isn’t being met to set it to true).

---

<div class="post-metadata">

### Author: ![jsuthe](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jsuthe/32/1656_2.png) [@jsuthe](https://discourse.cmake.org/u/jsuthe)
#### Post date: [August 14, 2021, 6:17pm UTC](https://discourse.cmake.org/t/findmpi-insists-on-fortran/3922/3 "2021-08-14T18:17:00Z")

</div>

Thanks for the tip. It turned out to be a corrupted MPI installation. The “Fortran” message just sent me down the wrong rabbit hole.
