- # Execute the ompi_info binary with the full path of the compiler wrapper
- # found, otherwise we run the risk of false positives.
- find_file(MPI_INFO_BIN ompi_info
- HINTS ${_mpi_c_compiler_path} ${_mpiexec_path}
- ${_cmake_c_compiler_path} ${_cmake_cxx_compiler_path}
- NO_DEFAULT_PATH
- NO_SYSTEM_ENVIRONMENT_PATH
- NO_CMAKE_SYSTEM_PATH)
- if (MPI_INFO_BIN)
- exec_program(${MPI_INFO_BIN}
- ARGS -v ompi full
- OUTPUT_VARIABLE OPENMPI_TYPE
- RETURN_VALUE OPENMPI_EXEC_RETURN)
- if (OPENMPI_EXEC_RETURN EQUAL 0)
- string(REGEX REPLACE ".*Open MPI: \([0-9]+\\.[0-9]*\\.?[0-9]*\).*" "\\1" OPENMPI_VERSION ${OPENMPI_TYPE})
- if (OPENMPI_VERSION VERSION_LESS "1.4.1")
- MESSAGE(WARNING
- "CMake found OpenMPI version ${OPENMPI_VERSION} on your system. "
- "There are known problems with GROMACS and OpenMPI version < 1.4.1. "
- "Please consider updating your OpenMPI if your MPI wrapper compilers "
- "are using the above OpenMPI version.")
- endif ()
- if (OPENMPI_VERSION VERSION_EQUAL "1.8.6")
- MESSAGE(WARNING
- "CMake found OpenMPI version ${OPENMPI_VERSION} on your system. "
- "This OpenMPI version is known to leak memory with GROMACS,"
- "please update to a more recent version. ")
- endif ()
- unset(OPENMPI_VERSION)
- unset(OPENMPI_TYPE)
- unset(OPENMPI_EXEC_RETURN)
- endif ()
+# Test for and warn about unsuitable OpenMPI versions.
+# TODO(#4093): Update tests with respect to required (compatible) OpenMPI versions.
+if (GMX_LIB_MPI AND OPENMPI_VERSION)
+ if (OPENMPI_VERSION VERSION_LESS "1.4.1")
+ MESSAGE(WARNING
+ "CMake found OpenMPI version ${OPENMPI_VERSION} on your system. "
+ "There are known problems with GROMACS and OpenMPI version < 1.4.1. "
+ "Please consider updating your OpenMPI if your MPI wrapper compilers "
+ "are using the above OpenMPI version.")
+ endif ()
+ if (OPENMPI_VERSION VERSION_EQUAL "1.8.6")
+ MESSAGE(WARNING
+ "CMake found OpenMPI version ${OPENMPI_VERSION} on your system. "
+ "This OpenMPI version is known to leak memory with GROMACS,"
+ "please update to a more recent version. ")