I have find_package(MPI REQUIRED) in my CMakeLists.txt. And there are two versions of mpi installed.
/opt/hpcx/ompi/lib;/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?
According to the documentation of the cmake
FindMPIpackage, 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_HOMEor the CMake variable:-D MPI_HOME=/your/mpi