From fa458957ab8b4debb5c17c6da51da436a65d5540 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 18 Jul 2008 08:17:23 -0400 Subject: [PATCH] ENH: Use the HINTS feature of find_library to find the right libraries for MPI, and act a bit more intelligently when MPI cannot be found. --- Modules/FindMPI.cmake | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index d568c94d5..03e95ef71 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -210,11 +210,11 @@ elseif (MPI_COMPILE_CMDLINE) foreach(LIB ${MPI_LIBNAMES}) string(REGEX REPLACE "^-l" "" LIB ${LIB}) set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) - find_library(MPI_LIB ${LIB} PATHS ${MPI_LINK_PATH}) + find_library(MPI_LIB ${LIB} HINTS ${MPI_LINK_PATH}) if (MPI_LIB) list(APPEND MPI_LIBRARIES ${MPI_LIB}) else (MPI_LIB) - status(ERROR "Unable to find MPI library ${LIB}") + message(SEND_ERROR "Unable to find MPI library ${LIB}") endif (MPI_LIB) endforeach(LIB) set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE INTERNAL "Scratch variable for MPI detection" FORCE) @@ -222,12 +222,13 @@ elseif (MPI_COMPILE_CMDLINE) # Chop MPI_LIBRARIES into the old-style MPI_LIBRARY and # MPI_EXTRA_LIBRARY. list(LENGTH MPI_LIBRARIES MPI_NUMLIBS) - if (MPI_NUMLIBS GREATER 0) + list(LENGTH MPI_LIBNAMES MPI_NUMLIBS_EXPECTED) + if (MPI_NUMLIBS EQUAL MPI_NUMLIBS_EXPECTED) list(GET MPI_LIBRARIES 0 MPI_LIBRARY_WORK) set(MPI_LIBRARY ${MPI_LIBRARY_WORK} CACHE FILEPATH "MPI library to link against" FORCE) - else (MPI_NUMLIBS GREATER 0) - set(MPI_LIBRARY "MPI_LIBRARY-NOTFOUND" CACHE STRING "MPI library to link against" FORCE) - endif (MPI_NUMLIBS GREATER 0) + else (MPI_NUMLIBS EQUAL MPI_NUMLIBS_EXPECTED) + set(MPI_LIBRARY "MPI_LIBRARY-NOTFOUND" CACHE FILEPATH "MPI library to link against" FORCE) + endif (MPI_NUMLIBS EQUAL MPI_NUMLIBS_EXPECTED) if (MPI_NUMLIBS GREATER 1) set(MPI_EXTRA_LIBRARY_WORK ${MPI_LIBRARIES}) list(REMOVE_AT MPI_EXTRA_LIBRARY_WORK 0)