1
- cmake_minimum_required (VERSION 3.0 )
1
+ cmake_minimum_required (VERSION 3.2 )
2
2
3
3
# Set the type/configuration of build to perform
4
4
set ( CMAKE_CONFIGURATION_TYPES "Debug" "Release" "MinSizeRel" "RelWithDebInfo" "CodeCoverage" )
@@ -90,7 +90,7 @@ the C compiler if it matches the Fortran compiler ID." )
90
90
endif ()
91
91
set ( CMAKE_Fortran_COMPILER_VERSION "${DETECTED_VER} " )
92
92
endif ()
93
-
93
+
94
94
# We have populated CMAKE_Fortran_COMPILER_VERSION if it was missing
95
95
if (gfortran_compiler AND (CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER 5.0.0 ))
96
96
set (opencoarrays_aware_compiler true )
@@ -155,7 +155,7 @@ endif()
155
155
156
156
find_package ( MPI )
157
157
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 ) )
159
159
find_program (MY_MPI_EXEC NAMES mpirun mpiexec lamexec srun
160
160
PATHS "${CMAKE_SOURCE_DIR/prerequisites/installations/mpich/3.1.4}" "${CMAKE_SOURCE_DIR} /prerequisites/installations/mpich/*" ENV PATH
161
161
HINTS "${FTN_COMPILER_DIR} " "${C_COMPILER_DIR} "
@@ -164,6 +164,46 @@ if ( (NOT MPI_C_FOUND) OR (NOT MPI_Fortran_FOUND) )
164
164
find_package ( MPI REQUIRED )
165
165
endif ()
166
166
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
+
167
207
#--------------------------------------------------------
168
208
# Make sure a simple "hello world" C mpi program compiles
169
209
#--------------------------------------------------------
0 commit comments