Skip to content

FindMPI: ENV{MPI_ROOT} with spectrum-mpi points to wrong include path

While working on LLNL's rzansel machine, we have run into an unexpected behavior for FindMPI.cmake for cmake-3.18.0. The following reproducer demonstrates the issue:

# CMakeLists.txt

# [Update 01/20/21] In my initial report, I had 'cmake_minimum_required' after 'project'. 
# Brad King noticed my mistake and I've updated this sample accordingly.  The change in 
# order doesn't fix the incorrect behavior.

# cmake_minimum_required(VERSION 3.18)
project(fm CXX C Fortran)

find_package(MPI)

message("
MPI_Fortran_COMPILE_OPTIONS = ${MPI_Fortran_COMPILE_OPTIONS}
MPI_Fortran_INCLUDE_DIRS = ${MPI_Fortran_INCLUDE_DIRS}
MPI_Fortran_LINK_FLAGS = ${MPI_Fortran_LINK_FLAGS}
")
  • As is, this CMakeLists.txt works as expected:
MPI_Fortran_COMPILE_OPTIONS = -pthread
MPI_Fortran_INCLUDE_DIRS = /usr/tce/packages/spectrum-mpi/ibm/spectrum-mpi-2020.08.19/include;/usr/tce/packages/spectrum-mpi/ibm/spectrum-mpi-2020.08.19/lib/gcc-8.3.1
MPI_Fortran_LINK_FLAGS = -Wl,-rpath,/usr/tce/packages/spectrum-mpi/ibm/spectrum-mpi-2020.08.19/lib -pthread
  • But if I uncomment the cmake_minimum_required line, FindMPI.cmake returns a different and incorrect value:
MPI_Fortran_COMPILE_OPTIONS = 
MPI_Fortran_INCLUDE_DIRS = /usr/tce/packages/spectrum-mpi/ibm/spectrum-mpi-2020.08.19/include;/usr/tce/packages/spectrum-mpi/ibm/spectrum-mpi-2020.08.19/lib/XL
MPI_Fortran_LINK_FLAGS = 
  • In particular, the INCLUDE_DIRS path is wrong and causes compile failure since we are expecting to find mpi.mod that works with gcc-8.3.1.

Do you have any suggestions for resolving this issue? Is this a bug?

Update 2021-01-20

  • If I leave the cmake_minimum_required line in the file and vary the VERSION value, I find that the incorrect behavior first occurs at version 3.12. Version 3.11 produced the expected gcc-8.3.1 path. but version 3.12 produces the incorrect XL path.
Edited by Brad King
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information