Skip to content
Snippets Groups Projects
Commit 5b73c112 authored by Franck Pérignon's avatar Franck Pérignon
Browse files

Update cmake mpi-fortran finder

parent 9025ddd8
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,7 @@
# MPI_Fortran_LIBRARIES All libraries to link MPI programs against
#
# F. Pérignon - LJK, Grenoble - march 2011.
# Inspired from original Kitware FindMPI.cmake (only for C/C++ MPI)
# Inspired from original Kitware FindMPI.cmake (which is written only for C/C++ MPI)
#
# If mpiexec is not set, that means MPI has not been searched. Forced it
......@@ -137,7 +137,7 @@ elseif (MPI_Fortran_COMPILE_CMDLINE)
separate_arguments(MPI_Fortran_INCLUDE_PATH_WORK)
endif (MPI_Fortran_COMPILER_MAY_HAVE_INCLIBDIRS)
endif (NOT MPI_Fortran_INCLUDE_PATH_WORK)
if (NOT MPI_Fortran_INCLUDE_PATH_WORK)
# If all else fails, just search for mpi.mod in the normal include
# paths.
......@@ -194,22 +194,22 @@ elseif (MPI_Fortran_COMPILE_CMDLINE)
find_library(MPI_Fortran_LIB ${LIB} HINTS ${MPI_Fortran_LINK_PATH})
if (MPI_Fortran_LIB)
list(APPEND MPI_Fortran_LIBRARIES ${MPI_Fortran_LIB})
else (MPI_LIB)
else()
message(SEND_ERROR "Unable to find MPI library ${LIB}")
endif (MPI_Fortran_LIB)
endif()
endforeach(LIB)
set(MPI_Fortran_LIB "MPI_LIB-NOTFOUND" CACHE INTERNAL "Scratch variable for MPI detection" FORCE)
# Chop MPI_LIBRARIES into the old-style MPI_LIBRARY and
# MPI_EXTRA_LIBRARY.
list(LENGTH MPI_Fortran_LIBRARIES MPI_Fortran_NUMLIBS)
list(LENGTH MPI_Fortran_LIBNAMES MPI_Fortran_NUMLIBS_EXPECTED)
if (MPI_Fortran_NUMLIBS EQUAL MPI_Fortran_NUMLIBS_EXPECTED)
if (MPI_Fortran_NUMLIBS GREATER MPI_Fortran_NUMLIBS_EXPECTED)
list(GET MPI_Fortran_LIBRARIES 0 MPI_Fortran_LIBRARY_WORK)
set(MPI_Fortran_LIBRARY ${MPI_Fortran_LIBRARY_WORK} CACHE FILEPATH "MPI library to link against" FORCE)
else (MPI_Fortran_NUMLIBS EQUAL MPI_Fortran_NUMLIBS_EXPECTED)
else()
set(MPI_Fortran_LIBRARY "MPI_Fortran_LIBRARY-NOTFOUND" CACHE FILEPATH "MPI library to link against" FORCE)
endif (MPI_Fortran_NUMLIBS EQUAL MPI_Fortran_NUMLIBS_EXPECTED)
endif()
if (MPI_Fortran_NUMLIBS GREATER 1)
set(MPI_Fortran_EXTRA_LIBRARY_WORK ${MPI_Fortran_LIBRARIES})
list(REMOVE_AT MPI_Fortran_EXTRA_LIBRARY_WORK 0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment