From fe7e5f6044a48e03cf3412769780268aaff132cf Mon Sep 17 00:00:00 2001 From: Peter Muench Date: Sat, 23 Nov 2024 14:51:14 +0100 Subject: [PATCH] Update the usage of MPIEXEC_EXECUTABLE/MPIEXEC --- cmake/modules/FindDEAL_II_MPI.cmake | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/cmake/modules/FindDEAL_II_MPI.cmake b/cmake/modules/FindDEAL_II_MPI.cmake index 8ad96111af..4e4bc249bd 100644 --- a/cmake/modules/FindDEAL_II_MPI.cmake +++ b/cmake/modules/FindDEAL_II_MPI.cmake @@ -41,11 +41,20 @@ endif() # Call the system FindMPI.cmake module: # -# in case MPIEXEC is specified first call find_program() so that in case of -# success its subsequent runs inside find_package(MPI) do not alter the -# desired result. -if(DEFINED ENV{MPIEXEC}) - find_program(MPIEXEC $ENV{MPIEXEC}) +# +# Make sure we pick up the correct MPI implementation for the case that +# environment variables MPIEXEC_EXECUTABLE, or MPIEXEC are set. If +# MPIEXEC_EXECUTABLE is already set as a CMake variable simply ignore the +# environment variables. +# +if(NOT MPIEXEC_EXECUTABLE) + if(DEFINED ENV{MPIEXEC_EXECUTABLE}) + find_program(MPIEXEC_EXECUTABLE $ENV{MPIEXEC_EXECUTABLE}) + elseif(DEFINED ENV{MPIEXEC}) + find_program(MPIEXEC_EXECUTABLE $ENV{MPIEXEC}) + endif() + # For backwards compatbility with old cmake versions: + set(MPIEXEC "${MPIEXEC_EXECUTABLE}") endif() find_package(MPI) -- 2.39.5