Reputation: 2686
I want to set a particular MPI compiler (mpiifort
) with CMake. Well, not the compiler, but get the libraries and include directories from it. But there is also mpif90
in the path, which uses gfortran
under the hood, and has a different set of include dirs and libraries. It seems the FindMPI
module in CMake insists on locating mpif90
first and therefore sets the wrong paths.
I've tried setting MPI_Fortran_COMPILER=mpiifort
in the command line, or setting FC=mpiifort
, but none works. So far the only workaround I've found is creating a symlink mpif90 -> mpiifort
in the current directory and adding _MPI_PREFIX_PATH=.
. Any other ideas?
EDIT: I had tried the environment variable MPI_Fortran_COMPILER
, but I had to set the CMake variable instead. So this worked:
FC=ifort CC=icc cmake -D MPI_Fortran_COMPILER=mpiifort ...
Upvotes: 1
Views: 1097
Reputation: 1707
According to the source here, if setting MPI_Fortran_COMPILER does not work, then you could simply set MPI_Fortran_LIBRARIES and MPI_Fortran_INCLUDE_PATH.
Upvotes: 1