CMake does not find MPI for Fortran.
I am on Arch Linux with CMake 3.19.2. I installed the openmpi (4.0.5-2) package and as stated here I also installed the gcc-fortran (10.2.0-4) package for fortran support.
I my CMake script in the line where MPI should be found:
find_package(MPI REQUIRED)
it tells me that it could not find MPI for Fortran:
-- Found MPI_C: /usr/lib/openmpi/libmpi.so (found version "3.1")
-- Found MPI_CXX: /usr/lib/openmpi/libmpi_cxx.so (found version "3.1")
-- Could NOT find MPI_Fortran (missing: MPI_Fortran_WORKS)
CMake Error at /usr/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:218 (message):
Could NOT find MPI (missing: MPI_Fortran_FOUND) (found version "3.1")
Call Stack (most recent call first):
/usr/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:582 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.19/Modules/FindMPI.cmake:1721 (find_package_handle_standard_args)
CMakeLists.txt:387 (find_package)
When installing openmpi it tells me that fortran support should be enabled:
(2/2) installing openmpi
Optional dependencies for openmpi
gcc-fortran: fortran support [installed]
There is a file /usr/lib/openmpi/libmpi_mpifh.so. Correct me if I am wrong but I think this should be the correct library file.
Thanks in advance for your help!
EDIT
I just tried to build a minimal example:
project(test)
cmake_minimum_required(VERSION 3.0)
enable_language(Fortran)
find_package(MPI REQUIRED)
With this it finds MPI_Fortran
-- Found MPI_Fortran: /usr/lib/openmpi/libmpi_usempif08.so (found version "3.1")
The CMakeLists.txt is a rather long and legacy one... Seems that I have to find the solution on my own.
/usr/lib/openmpi/mpi.mod
exists and that you are not setting some strange value toFC
. – Hristo Iliev