From 91a174d6f8be823962aa01eb30257f579541646d Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Tue, 1 May 2018 18:39:02 -0500 Subject: [PATCH] CMake: Fix MPI version detection for newer cmake --- cmake/modules/FindMPI.cmake | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/cmake/modules/FindMPI.cmake b/cmake/modules/FindMPI.cmake index 5b5efb0195..8a899213c5 100644 --- a/cmake/modules/FindMPI.cmake +++ b/cmake/modules/FindMPI.cmake @@ -78,7 +78,19 @@ CHECK_CXX_SOURCE_COMPILES( RESET_CMAKE_REQUIRED() # -# Manually assemble some version information: +# Newer versions of FindMPI.cmake only populate MPI_CXX_* (and MPI_C_*, +# MPI_Fortran_*) variables. Let's rename these version names +# + +IF(NOT DEFINED MPI_VERSION AND DEFINED MPI_CXX_VERSION) + SET(MPI_VERSION ${MPI_CXX_VERSION}) + SET(MPI_VERSION_MAJOR ${MPI_CXX_VERSION_MAJOR}) + SET(MPI_VERSION_MINOR ${MPI_CXX_VERSION_MINOR}) +ENDIF() + +# +# Really old versions of CMake do not export any version information. In +# this case, query the mpi.h header for the necessary information: # DEAL_II_FIND_FILE(MPI_MPI_H @@ -97,11 +109,6 @@ IF(NOT MPI_MPI_H MATCHES "-NOTFOUND" AND NOT DEFINED MPI_VERSION) MPI_VERSION_MINOR "${MPI_VERSION_MINOR_STRING}" ) SET(MPI_VERSION "${MPI_VERSION_MAJOR}.${MPI_VERSION_MINOR}") - IF("${MPI_VERSION}" STREQUAL ".") - SET(MPI_VERSION) - SET(MPI_VERSION_MAJOR) - SET(MPI_VERSION_MINOR) - ENDIF() ENDIF() DEAL_II_PACKAGE_HANDLE(MPI -- 2.39.5