1- cmake_minimum_required (VERSION 3.0 )
1+ cmake_minimum_required (VERSION 3.2 )
22
33# Set the type/configuration of build to perform
44set ( CMAKE_CONFIGURATION_TYPES "Debug" "Release" "MinSizeRel" "RelWithDebInfo" "CodeCoverage" )
@@ -90,7 +90,7 @@ the C compiler if it matches the Fortran compiler ID." )
9090 endif ()
9191 set ( CMAKE_Fortran_COMPILER_VERSION "${DETECTED_VER} " )
9292endif ()
93-
93+
9494 # We have populated CMAKE_Fortran_COMPILER_VERSION if it was missing
9595 if (gfortran_compiler AND (CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER 5.0.0))
9696 set (opencoarrays_aware_compiler true )
@@ -155,7 +155,7 @@ endif()
155155
156156find_package ( MPI )
157157
158- if ( (NOT MPI_C_FOUND) OR (NOT MPI_Fortran_FOUND) )
158+ if ( (NOT MPI_C_FOUND) OR (NOT MPI_Fortran_FOUND) OR ( NOT MPIEXEC) )
159159 find_program (MY_MPI_EXEC NAMES mpirun mpiexec lamexec srun
160160 PATHS "${CMAKE_SOURCE_DIR/prerequisites/installations/mpich/3.1.4}" "${CMAKE_SOURCE_DIR} /prerequisites/installations/mpich/*" ENV PATH
161161 HINTS "${FTN_COMPILER_DIR} " "${C_COMPILER_DIR} "
@@ -164,6 +164,46 @@ if ( (NOT MPI_C_FOUND) OR (NOT MPI_Fortran_FOUND) )
164164 find_package ( MPI REQUIRED )
165165endif ()
166166
167+ # Test for consistent MPI environment
168+ if (NOT MPIEXEC)
169+ message ( ERROR "CMake failed to find `mpiexec` or similar. If building with `./install.sh` please
170+ report this bug to the OpenCoarrays developers at
171+ https://github.com/sourceryinstitute/opencoarrays/issues, otherwise use point CMake
172+ to the desired MPI runtime." )
173+ endif ()
174+
175+ get_filename_component (MPIEXEC_RELATIVE_LOC "${MPIEXEC} "
176+ PROGRAM )
177+ get_filename_component (MPIEXEC_ABS_LOC "${MPIEXEC_RELATIVE_LOC} "
178+ REALPATH)
179+ get_filename_component (MPIEXEC_DIR "${MPIEXEC_ABS_LOC} "
180+ DIRECTORY )
181+
182+ get_filename_component (MPICC_RELATIVE_LOC "${MPI_C_COMPILER} "
183+ PROGRAM )
184+ get_filename_component (MPICC_ABS_LOC "${MPICC_RELATIVE_LOC} "
185+ REALPATH)
186+ get_filename_component (MPICC_DIR "${MPICC_ABS_LOC} "
187+ DIRECTORY )
188+
189+ get_filename_component (MPIFC_RELATIVE_LOC "${MPI_Fortran_COMPILER} "
190+ PROGRAM )
191+ get_filename_component (MPIFC_ABS_LOC "${MPIFC_RELATIVE_LOC} "
192+ REALPATH)
193+ get_filename_component (MPIFC_DIR "${MPIFC_ABS_LOC} "
194+ DIRECTORY )
195+
196+ if ((MPIEXEC_DIR STREQUAL MPICC_DIR) AND (MPIEXEC_DIR STREQUAL MPIFC_DIR))
197+ message ( STATUS "MPI runtime and compile time environments appear to be consistent" )
198+ else ()
199+ message ( WARNING "MPIEXEC is in \" ${MPIEXEC_DIR} ,\"
200+ which differs from the location of MPICC and/or MPIFC which are in
201+ \" ${MPICC_DIR} \" and \" ${MPIFC_DIR} ,\" respectively.
202+ This is likely indicative of a problem. If building with `./install.sh` please report
203+ this to the OpenCoarrays developers by filing a new issue at:
204+ https://github.com/sourceryinstitute/OpenCoarrays/issues/new" )
205+ endif ()
206+
167207#--------------------------------------------------------
168208# Make sure a simple "hello world" C mpi program compiles
169209#--------------------------------------------------------
0 commit comments