FindMPI insists on Fortran

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:


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:

    Could NOT find MPI (missing: MPI_CXX_FOUND CXX)

    and don’t include the “Fortran” message.

  • On OSX, there is no problem.

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

I’ve seen some discussion here, 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…

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).

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