find_package(MPI REQUIRED) is not locating the right mpi

66 Views Asked by At

I have find_package(MPI REQUIRED) in my CMakeLists.txt. And there are two versions of mpi installed.

  1. /opt/hpcx/ompi/lib;
  2. /usr/local/mpi/lib;

Everytime I run CMake, it choose /opt/hpcx/ompi/lib.

-- Found MPI (include: , library: /opt/hpcx/ompi/lib/libmpi.so)

What do I need to do to make it locate the one under /usr/local/mpi/lib?

1

There are 1 best solutions below

0
Victor Eijkhout On

According to the documentation of the cmake FindMPI package, there are various environment variables you can set to force it to find your preferred MPI.

See: https://cmake.org/cmake/help/latest/module/FindMPI.html

You can set the environment variable MPI_HOME or the CMake variable: -D MPI_HOME=/your/mpi