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 ...
答案 0 :(得分:1)
根据源here,如果设置MPI_Fortran_COMPILER不起作用,那么您只需设置MPI_Fortran_LIBRARIES和MPI_Fortran_INCLUDE_PATH。