Skip to content

Commit 44bf52e

Browse files
committed
Fix MPI search path
See #253 (comment)
1 parent 1eb9ce1 commit 44bf52e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,18 @@ endif()
106106
#----------------------------------------------------------------------------
107107
# Find MPI and set some flags so that FC and CC can point to gfortran and gcc
108108
#----------------------------------------------------------------------------
109-
find_package(MPI REQUIRED)
109+
110+
# If the user passes FC=mpif90 etc. check and prefer that location
111+
get_filename_component( FTN_MPI_DIR "${CMAKE_Fortran_COMPILER}"
112+
REALPATH )
113+
get_filename_component( C_MPI_DIR "${CMAKE_C_COMPILER}"
114+
REALPATH )
115+
set ( MPI_HOME "${MPI_HOME}" "${FTN_MPI_DIR}/.." "${C_MPI_DIR}/.." )
116+
117+
# Check the install.sh defaut mpich installation directories
118+
set ( MPI_HOME "${MPI_HOME}" "${CMAKE_SOURCE_DIR}/prerequisites/installations/mpich/3.1.4" "${CMAKE_SOURCE_DIR}/prerequisites/installations/mpich/*" )
119+
120+
find_package( MPI REQUIRED )
110121

111122
set(CMAKE_C_COMPILE_FLAGS ${CMAKE_C_COMPILE_FLAGS} ${MPI_C_COMPILE_FLAGS})
112123
set(CMAKE_C_LINK_FLAGS ${CMAKE_C_LINK_FLAGS} ${MPI_C_LINK_FLAGS})

0 commit comments

Comments
 (0)