2008-03-31 18:55:32 +04:00
# - Message Passing Interface (MPI) module.
2009-10-27 19:43:50 +03:00
#
2008-03-31 18:55:32 +04:00
# The Message Passing Interface (MPI) is a library used to write
# high-performance parallel applications that use message passing, and
# is typically deployed on a cluster. MPI is a standard interface
# (defined by the MPI forum) for which many implementations are
# available. All of these implementations have somewhat different
# compilation approaches (different include paths, libraries to link
# against, etc.), and this module tries to smooth out those differences.
2008-03-08 03:58:29 +03:00
#
# This module will set the following variables:
# MPI_FOUND TRUE if we have found MPI
# MPI_COMPILE_FLAGS Compilation flags for MPI programs
2008-03-31 18:55:32 +04:00
# MPI_INCLUDE_PATH Include path(s) for MPI header
2008-03-08 03:58:29 +03:00
# MPI_LINK_FLAGS Linking flags for MPI programs
2008-03-31 18:55:32 +04:00
# MPI_LIBRARY First MPI library to link against (cached)
# MPI_EXTRA_LIBRARY Extra MPI libraries to link against (cached)
# MPI_LIBRARIES All libraries to link MPI programs against
2008-03-08 03:58:29 +03:00
# MPIEXEC Executable for running MPI programs
2008-03-31 18:55:32 +04:00
# MPIEXEC_NUMPROC_FLAG Flag to pass to MPIEXEC before giving it the
# number of processors to run on
# MPIEXEC_PREFLAGS Flags to pass to MPIEXEC directly before the
# executable to run.
# MPIEXEC_POSTFLAGS Flags to pass to MPIEXEC after all other flags.
2008-03-08 03:58:29 +03:00
#
# This module will attempt to auto-detect these settings, first by
2008-03-31 18:55:32 +04:00
# looking for a MPI compiler, which many MPI implementations provide
# as a pass-through to the native compiler to simplify the compilation
# of MPI programs. The MPI compiler is stored in the cache variable
# MPI_COMPILER, and will attempt to look for commonly-named drivers
# mpic++, mpicxx, mpiCC, or mpicc. If the compiler driver is found and
# recognized, it will be used to set all of the module variables. To
# skip this auto-detection, set MPI_LIBRARY and MPI_INCLUDE_PATH in
# the CMake cache.
#
# If no compiler driver is found or the compiler driver is not
# recognized, this module will then search for common include paths
2009-10-27 19:43:50 +03:00
# and library names to try to detect MPI.
2008-03-31 18:55:32 +04:00
#
# If CMake initially finds a different MPI than was intended, and you
# want to use the MPI compiler auto-detection for a different MPI
# implementation, set MPI_COMPILER to the MPI compiler driver you want
# to use (e.g., mpicxx) and then set MPI_LIBRARY to the string
# MPI_LIBRARY-NOTFOUND. When you re-configure, auto-detection of MPI
# will run again with the newly-specified MPI_COMPILER.
#
# When using MPIEXEC to execute MPI applications, you should typically
# use all of the MPIEXEC flags as follows:
# ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} PROCS ${MPIEXEC_PREFLAGS} EXECUTABLE
# ${MPIEXEC_POSTFLAGS} ARGS
# where PROCS is the number of processors on which to execute the program,
2009-10-27 19:43:50 +03:00
# EXECUTABLE is the MPI program, and ARGS are the arguments to pass to the
2008-03-31 18:55:32 +04:00
# MPI program.
2001-12-12 19:51:03 +03:00
2009-09-28 19:45:50 +04:00
#=============================================================================
# Copyright 2001-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distributed this file outside of CMake, substitute the full
# License text for the above reference.)
2009-10-27 19:43:50 +03:00
# This module is maintained by David Partyka <dave.partyka@kitware.com>.
# A set of directories to search through in addition to the standard system paths
# that find_program will search through.
# Microsoft HPC SDK is automatically added to the system path
# Argonne National Labs MPICH2 sets a registry key that we can use.
2008-03-08 03:58:29 +03:00
2009-11-13 18:57:01 +03:00
set ( _MPI_PACKAGE_DIR
2009-10-27 19:43:50 +03:00
m p i
m p i c h
o p e n m p i
l i b / m p i
l i b / m p i c h
l i b / o p e n m p i
" M P I C H / S D K "
" M i c r o s o f t C o m p u t e C l u s t e r P a c k "
)
2009-11-13 18:57:01 +03:00
set ( _MPI_PREFIX_PATH )
2009-10-27 19:43:50 +03:00
if ( WIN32 )
2009-11-13 18:57:01 +03:00
list ( APPEND _MPI_PREFIX_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH\\SMPD;binary]/.." )
2009-10-27 19:43:50 +03:00
endif ( )
foreach ( SystemPrefixDir ${ CMAKE_SYSTEM_PREFIX_PATH } )
2009-11-13 18:57:01 +03:00
foreach ( MpiPackageDir ${ _MPI_PREFIX_PATH } )
2009-10-27 19:43:50 +03:00
if ( EXISTS ${ SystemPrefixDir } / ${ MpiPackageDir } )
2009-11-13 18:57:01 +03:00
list ( APPEND _MPI_PREFIX_PATH "${SystemPrefixDir}/${MpiPackageDir}" )
2009-10-27 19:43:50 +03:00
endif ( )
endforeach ( MpiPackageDir )
endforeach ( SystemPrefixDir )
# Most mpi distros have some form of mpiexec which gives us something we can reliably look for.
2008-03-08 03:58:29 +03:00
find_program ( MPIEXEC
2008-03-31 18:55:32 +04:00
N A M E S m p i e x e c m p i r u n l a m e x e c
2009-11-13 18:57:01 +03:00
P A T H S $ { _ M P I _ P R E F I X _ P A T H }
2009-10-27 19:43:50 +03:00
P A T H _ S U F F I X E S b i n
D O C " E x e c u t a b l e f o r r u n n i n g M P I p r o g r a m s . "
)
# call get_filename_component twice to remove mpiexec and the directory it exists in (typically bin).
# This gives us a fairly reliable base directory to search for /bin /lib and /include from.
2009-11-13 18:52:28 +03:00
get_filename_component ( _MPI_BASE_DIR "${MPIEXEC}" PATH )
get_filename_component ( _MPI_BASE_DIR "${_MPI_BASE_DIR}" PATH )
2009-10-27 19:43:50 +03:00
# If there is an mpi compiler find it and interogate (farther below) it for the include
2009-11-13 18:52:28 +03:00
# and lib dirs otherwise we will continue to search from ${_MPI_BASE_DIR}.
2009-10-27 19:43:50 +03:00
find_program ( MPI_COMPILER
N A M E S m p i c + + m p i c x x m p i C C m p i c c
2009-11-13 18:52:28 +03:00
H I N T S " $ { _ M P I _ B A S E _ D I R } "
2009-10-27 19:43:50 +03:00
P A T H _ S U F F I X E S b i n
D O C " M P I c o m p i l e r . U s e d o n l y t o d e t e c t M P I c o m p i l a t i o n f l a g s . " )
mark_as_advanced ( MPI_COMPILER )
2008-03-08 03:58:29 +03:00
2008-03-31 18:55:32 +04:00
set ( MPIEXEC_NUMPROC_FLAG "-np" CACHE STRING "Flag used by MPI to specify the number of processes for MPIEXEC; the next option will be the number of processes." )
set ( MPIEXEC_PREFLAGS "" CACHE STRING "These flags will be directly before the executable that is being run by MPIEXEC." )
set ( MPIEXEC_POSTFLAGS "" CACHE STRING "These flags will come after all flags given to MPIEXEC." )
set ( MPIEXEC_MAX_NUMPROCS "2" CACHE STRING "Maximum number of processors available to run MPI applications." )
2009-10-27 19:43:50 +03:00
mark_as_advanced ( MPIEXEC MPIEXEC_NUMPROC_FLAG MPIEXEC_PREFLAGS
2008-03-31 18:55:32 +04:00
M P I E X E C _ P O S T F L A G S M P I E X E C _ M A X _ N U M P R O C S )
2008-03-08 03:58:29 +03:00
2008-03-31 18:55:32 +04:00
if ( MPI_INCLUDE_PATH AND MPI_LIBRARY )
# Do nothing: we already have MPI_INCLUDE_PATH and MPI_LIBRARY in
# the cache, and we don't want to override those settings.
elseif ( MPI_COMPILER )
2008-03-08 03:58:29 +03:00
# Check whether the -showme:compile option works. This indicates
# that we have either Open MPI or a newer version of LAM-MPI, and
# implies that -showme:link will also work.
2009-10-27 19:43:50 +03:00
# Note that Windows distros do not have an mpi compiler to interogate.
exec_program ( ${ MPI_COMPILER }
A R G S - s h o w m e : c o m p i l e
2008-03-08 03:58:29 +03:00
O U T P U T _ V A R I A B L E M P I _ C O M P I L E _ C M D L I N E
2008-03-31 18:55:32 +04:00
R E T U R N _ V A L U E M P I _ C O M P I L E R _ R E T U R N )
2008-03-08 03:58:29 +03:00
2008-03-31 18:55:32 +04:00
if ( MPI_COMPILER_RETURN EQUAL 0 )
2008-03-08 03:58:29 +03:00
# If we appear to have -showme:compile, then we should also have
# -showme:link. Try it.
2009-10-27 19:43:50 +03:00
exec_program ( ${ MPI_COMPILER }
2008-03-08 03:58:29 +03:00
A R G S - s h o w m e : l i n k
O U T P U T _ V A R I A B L E M P I _ L I N K _ C M D L I N E
2008-03-31 18:55:32 +04:00
R E T U R N _ V A L U E M P I _ C O M P I L E R _ R E T U R N )
2008-04-22 17:41:07 +04:00
# Note that we probably have -showme:incdirs and -showme:libdirs
# as well.
set ( MPI_COMPILER_MAY_HAVE_INCLIBDIRS TRUE )
2008-03-31 18:55:32 +04:00
endif ( MPI_COMPILER_RETURN EQUAL 0 )
2008-03-08 03:58:29 +03:00
2008-03-31 18:55:32 +04:00
if ( MPI_COMPILER_RETURN EQUAL 0 )
2008-03-08 03:58:29 +03:00
# Do nothing: we have our command lines now
2008-03-31 18:55:32 +04:00
else ( MPI_COMPILER_RETURN EQUAL 0 )
2008-03-08 03:58:29 +03:00
# Older versions of LAM-MPI have "-showme". Try it.
2009-10-27 19:43:50 +03:00
exec_program ( ${ MPI_COMPILER }
2008-03-08 03:58:29 +03:00
A R G S - s h o w m e
O U T P U T _ V A R I A B L E M P I _ C O M P I L E _ C M D L I N E
2008-03-31 18:55:32 +04:00
R E T U R N _ V A L U E M P I _ C O M P I L E R _ R E T U R N )
2009-10-27 19:43:50 +03:00
endif ( MPI_COMPILER_RETURN EQUAL 0 )
2008-03-08 03:58:29 +03:00
2008-03-31 18:55:32 +04:00
if ( MPI_COMPILER_RETURN EQUAL 0 )
2008-03-08 03:58:29 +03:00
# Do nothing: we have our command lines now
2008-03-31 18:55:32 +04:00
else ( MPI_COMPILER_RETURN EQUAL 0 )
2008-03-08 03:58:29 +03:00
# MPICH uses "-show". Try it.
2009-10-27 19:43:50 +03:00
exec_program ( ${ MPI_COMPILER }
2008-03-08 03:58:29 +03:00
A R G S - s h o w
O U T P U T _ V A R I A B L E M P I _ C O M P I L E _ C M D L I N E
2008-03-31 18:55:32 +04:00
R E T U R N _ V A L U E M P I _ C O M P I L E R _ R E T U R N )
2009-10-27 19:43:50 +03:00
endif ( MPI_COMPILER_RETURN EQUAL 0 )
2008-03-08 03:58:29 +03:00
2008-03-31 18:55:32 +04:00
if ( MPI_COMPILER_RETURN EQUAL 0 )
2008-03-08 03:58:29 +03:00
# We have our command lines, but we might need to copy
# MPI_COMPILE_CMDLINE into MPI_LINK_CMDLINE, if the underlying
if ( NOT MPI_LINK_CMDLINE )
SET ( MPI_LINK_CMDLINE ${ MPI_COMPILE_CMDLINE } )
endif ( NOT MPI_LINK_CMDLINE )
2008-03-31 18:55:32 +04:00
else ( MPI_COMPILER_RETURN EQUAL 0 )
message ( STATUS "Unable to determine MPI from MPI driver ${MPI_COMPILER}" )
endif ( MPI_COMPILER_RETURN EQUAL 0 )
endif ( MPI_INCLUDE_PATH AND MPI_LIBRARY )
2008-03-08 03:58:29 +03:00
2008-03-31 18:55:32 +04:00
if ( MPI_INCLUDE_PATH AND MPI_LIBRARY )
# Do nothing: we already have MPI_INCLUDE_PATH and MPI_LIBRARY in
# the cache, and we don't want to override those settings.
2008-03-08 03:58:29 +03:00
elseif ( MPI_COMPILE_CMDLINE )
# Extract compile flags from the compile command line.
2008-03-31 18:55:32 +04:00
string ( REGEX MATCHALL "-D([^\" ]+|\ "[^\" ]+\ ")" MPI_ALL_COMPILE_FLAGS "${MPI_COMPILE_CMDLINE}" )
2008-03-08 03:58:29 +03:00
set ( MPI_COMPILE_FLAGS_WORK )
foreach ( FLAG ${ MPI_ALL_COMPILE_FLAGS } )
if ( MPI_COMPILE_FLAGS_WORK )
set ( MPI_COMPILE_FLAGS_WORK "${MPI_COMPILE_FLAGS_WORK} ${FLAG}" )
else ( MPI_COMPILE_FLAGS_WORK )
set ( MPI_COMPILE_FLAGS_WORK ${ FLAG } )
endif ( MPI_COMPILE_FLAGS_WORK )
endforeach ( FLAG )
# Extract include paths from compile command line
2008-03-31 18:55:32 +04:00
string ( REGEX MATCHALL "-I([^\" ]+|\ "[^\" ]+\ ")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}" )
set ( MPI_INCLUDE_PATH_WORK )
foreach ( IPATH ${ MPI_ALL_INCLUDE_PATHS } )
string ( REGEX REPLACE "^-I" "" IPATH ${ IPATH } )
string ( REGEX REPLACE "//" "/" IPATH ${ IPATH } )
list ( APPEND MPI_INCLUDE_PATH_WORK ${ IPATH } )
endforeach ( IPATH )
2009-10-27 19:43:50 +03:00
2008-04-22 17:41:07 +04:00
if ( NOT MPI_INCLUDE_PATH_WORK )
if ( MPI_COMPILER_MAY_HAVE_INCLIBDIRS )
# The compile command line didn't have any include paths on it,
# but we may have -showme:incdirs. Use it.
2009-10-27 19:43:50 +03:00
exec_program ( ${ MPI_COMPILER }
2008-04-22 17:41:07 +04:00
A R G S - s h o w m e : i n c d i r s
O U T P U T _ V A R I A B L E M P I _ I N C L U D E _ P A T H _ W O R K
R E T U R N _ V A L U E M P I _ C O M P I L E R _ R E T U R N )
separate_arguments ( MPI_INCLUDE_PATH_WORK )
endif ( MPI_COMPILER_MAY_HAVE_INCLIBDIRS )
endif ( NOT MPI_INCLUDE_PATH_WORK )
2008-04-22 17:54:23 +04:00
if ( NOT MPI_INCLUDE_PATH_WORK )
# If all else fails, just search for mpi.h in the normal include
# paths.
2009-10-27 19:43:50 +03:00
find_path ( MPI_INCLUDE_PATH mpi.h
2009-11-13 18:57:01 +03:00
H I N T S $ { _ M P I _ B A S E _ D I R } $ { _ M P I _ P R E F I X _ P A T H }
2009-10-27 19:43:50 +03:00
P A T H _ S U F F I X E S i n c l u d e
)
2008-04-22 17:54:23 +04:00
set ( MPI_INCLUDE_PATH_WORK ${ MPI_INCLUDE_PATH } )
endif ( NOT MPI_INCLUDE_PATH_WORK )
2008-03-08 03:58:29 +03:00
# Extract linker paths from the link command line
2008-03-31 18:55:32 +04:00
string ( REGEX MATCHALL "-L([^\" ]+|\ "[^\" ]+\ ")" MPI_ALL_LINK_PATHS "${MPI_LINK_CMDLINE}" )
set ( MPI_LINK_PATH )
foreach ( LPATH ${ MPI_ALL_LINK_PATHS } )
string ( REGEX REPLACE "^-L" "" LPATH ${ LPATH } )
string ( REGEX REPLACE "//" "/" LPATH ${ LPATH } )
list ( APPEND MPI_LINK_PATH ${ LPATH } )
endforeach ( LPATH )
2007-06-22 18:22:27 +04:00
2008-04-22 17:41:07 +04:00
if ( NOT MPI_LINK_PATH )
if ( MPI_COMPILER_MAY_HAVE_INCLIBDIRS )
# The compile command line didn't have any linking paths on it,
# but we may have -showme:libdirs. Use it.
2009-10-27 19:43:50 +03:00
exec_program ( ${ MPI_COMPILER }
2008-04-22 17:41:07 +04:00
A R G S - s h o w m e : l i b d i r s
O U T P U T _ V A R I A B L E M P I _ L I N K _ P A T H
R E T U R N _ V A L U E M P I _ C O M P I L E R _ R E T U R N )
separate_arguments ( MPI_LINK_PATH )
endif ( MPI_COMPILER_MAY_HAVE_INCLIBDIRS )
endif ( NOT MPI_LINK_PATH )
2008-03-08 03:58:29 +03:00
# Extract linker flags from the link command line
2008-03-31 18:55:32 +04:00
string ( REGEX MATCHALL "-Wl,([^\" ]+|\ "[^\" ]+\ ")" MPI_ALL_LINK_FLAGS "${MPI_LINK_CMDLINE}" )
2008-03-08 03:58:29 +03:00
set ( MPI_LINK_FLAGS_WORK )
foreach ( FLAG ${ MPI_ALL_LINK_FLAGS } )
if ( MPI_LINK_FLAGS_WORK )
set ( MPI_LINK_FLAGS_WORK "${MPI_LINK_FLAGS_WORK} ${FLAG}" )
else ( MPI_LINK_FLAGS_WORK )
set ( MPI_LINK_FLAGS_WORK ${ FLAG } )
endif ( MPI_LINK_FLAGS_WORK )
endforeach ( FLAG )
# Extract the set of libraries to link against from the link command
# line
2008-03-31 18:55:32 +04:00
string ( REGEX MATCHALL "-l([^\" ]+|\ "[^\" ]+\ ")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}" )
2008-03-08 03:58:29 +03:00
# Determine full path names for all of the libraries that one needs
# to link against in an MPI program
set ( MPI_LIBRARIES )
foreach ( LIB ${ MPI_LIBNAMES } )
string ( REGEX REPLACE "^-l" "" LIB ${ LIB } )
set ( MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE )
2008-07-18 16:17:23 +04:00
find_library ( MPI_LIB ${ LIB } HINTS ${ MPI_LINK_PATH } )
2008-03-08 03:58:29 +03:00
if ( MPI_LIB )
list ( APPEND MPI_LIBRARIES ${ MPI_LIB } )
else ( MPI_LIB )
2008-07-18 16:17:23 +04:00
message ( SEND_ERROR "Unable to find MPI library ${LIB}" )
2008-03-08 03:58:29 +03:00
endif ( MPI_LIB )
endforeach ( LIB )
set ( MPI_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_LIBRARIES MPI_NUMLIBS )
2008-07-18 16:17:23 +04:00
list ( LENGTH MPI_LIBNAMES MPI_NUMLIBS_EXPECTED )
if ( MPI_NUMLIBS EQUAL MPI_NUMLIBS_EXPECTED )
2008-03-31 18:55:32 +04:00
list ( GET MPI_LIBRARIES 0 MPI_LIBRARY_WORK )
set ( MPI_LIBRARY ${ MPI_LIBRARY_WORK } CACHE FILEPATH "MPI library to link against" FORCE )
2008-07-18 16:17:23 +04:00
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 )
2008-03-08 03:58:29 +03:00
if ( MPI_NUMLIBS GREATER 1 )
2008-03-31 18:55:32 +04:00
set ( MPI_EXTRA_LIBRARY_WORK ${ MPI_LIBRARIES } )
list ( REMOVE_AT MPI_EXTRA_LIBRARY_WORK 0 )
set ( MPI_EXTRA_LIBRARY ${ MPI_EXTRA_LIBRARY_WORK } CACHE STRING "Extra MPI libraries to link against" FORCE )
2008-03-08 03:58:29 +03:00
else ( MPI_NUMLIBS GREATER 1 )
2008-03-31 18:55:32 +04:00
set ( MPI_EXTRA_LIBRARY "MPI_EXTRA_LIBRARY-NOTFOUND" CACHE STRING "Extra MPI libraries to link against" FORCE )
2008-03-08 03:58:29 +03:00
endif ( MPI_NUMLIBS GREATER 1 )
# Set up all of the appropriate cache entries
2008-03-31 18:55:32 +04:00
set ( MPI_COMPILE_FLAGS ${ MPI_COMPILE_FLAGS_WORK } CACHE STRING "MPI compilation flags" FORCE )
set ( MPI_INCLUDE_PATH ${ MPI_INCLUDE_PATH_WORK } CACHE STRING "MPI include path" FORCE )
set ( MPI_LINK_FLAGS ${ MPI_LINK_FLAGS_WORK } CACHE STRING "MPI linking flags" FORCE )
2008-03-08 03:58:29 +03:00
else ( MPI_COMPILE_CMDLINE )
2009-10-27 19:43:50 +03:00
# No MPI compiler to interogate so attempt to find everything with find functions.
find_path ( MPI_INCLUDE_PATH mpi.h
2009-11-13 18:57:01 +03:00
H I N T S $ { _ M P I _ B A S E _ D I R } $ { _ M P I _ P R E F I X _ P A T H }
2009-10-27 19:43:50 +03:00
P A T H _ S U F F I X E S i n c l u d e
2008-03-08 03:58:29 +03:00
)
2009-09-05 02:02:05 +04:00
2008-04-11 00:54:20 +04:00
# Decide between 32-bit and 64-bit libraries for Microsoft's MPI
2009-10-27 19:57:30 +03:00
if ( "${CMAKE_SIZEOF_VOID_P}" EQUAL 8 )
2008-04-11 00:54:20 +04:00
set ( MS_MPI_ARCH_DIR amd64 )
2009-10-27 19:43:50 +03:00
else ( )
2008-04-11 00:54:20 +04:00
set ( MS_MPI_ARCH_DIR i386 )
2009-10-27 19:43:50 +03:00
endif ( )
2009-09-05 02:02:05 +04:00
2009-10-27 19:43:50 +03:00
find_library ( MPI_LIBRARY
2008-04-11 00:54:20 +04:00
N A M E S m p i m p i c h m s m p i
2009-11-13 18:57:01 +03:00
H I N T S $ { _ M P I _ B A S E _ D I R } $ { _ M P I _ P R E F I X _ P A T H }
2009-10-27 19:43:50 +03:00
P A T H _ S U F F I X E S l i b l i b / $ { M S _ M P I _ A R C H _ D I R } L i b L i b / $ { M S _ M P I _ A R C H _ D I R }
2008-03-08 03:58:29 +03:00
)
2009-10-27 19:43:50 +03:00
find_library ( MPI_EXTRA_LIBRARY
2008-03-08 03:58:29 +03:00
N A M E S m p i + +
2009-11-13 18:57:01 +03:00
H I N T S $ { _ M P I _ B A S E _ D I R } $ { _ M P I _ P R E F I X _ P A T H }
2009-10-27 19:43:50 +03:00
P A T H _ S U F F I X E S l i b
2008-03-31 18:55:32 +04:00
D O C " E x t r a M P I l i b r a r i e s t o l i n k a g a i n s t . " )
2008-03-08 03:58:29 +03:00
set ( MPI_COMPILE_FLAGS "" CACHE STRING "MPI compilation flags" )
set ( MPI_LINK_FLAGS "" CACHE STRING "MPI linking flags" )
2008-03-31 18:55:32 +04:00
endif ( MPI_INCLUDE_PATH AND MPI_LIBRARY )
2008-03-08 03:58:29 +03:00
# on BlueGene/L the MPI lib is named libmpich.rts.a, there also these additional libs are required
if ( "${MPI_LIBRARY}" MATCHES "mpich.rts" )
set ( MPI_EXTRA_LIBRARY ${ MPI_EXTRA_LIBRARY } msglayer.rts devices.rts rts.rts devices.rts )
set ( MPI_LIBRARY ${ MPI_LIBRARY } msglayer.rts devices.rts rts.rts devices.rts )
endif ( "${MPI_LIBRARY}" MATCHES "mpich.rts" )
2007-08-06 19:02:58 +04:00
2009-10-27 19:43:50 +03:00
# Set up extra variables to conform to
2008-03-31 18:55:32 +04:00
if ( MPI_EXTRA_LIBRARY )
set ( MPI_LIBRARIES ${ MPI_LIBRARY } ${ MPI_EXTRA_LIBRARY } )
else ( MPI_EXTRA_LIBRARY )
set ( MPI_LIBRARIES ${ MPI_LIBRARY } )
endif ( MPI_EXTRA_LIBRARY )
if ( MPI_INCLUDE_PATH AND MPI_LIBRARY )
set ( MPI_FOUND TRUE )
else ( MPI_INCLUDE_PATH AND MPI_LIBRARY )
set ( MPI_FOUND FALSE )
endif ( MPI_INCLUDE_PATH AND MPI_LIBRARY )
2007-08-06 19:02:58 +04:00
2008-03-08 03:58:29 +03:00
include ( FindPackageHandleStandardArgs )
2009-10-27 19:43:50 +03:00
# handle the QUIETLY and REQUIRED arguments
2008-03-08 03:58:29 +03:00
find_package_handle_standard_args ( MPI DEFAULT_MSG MPI_LIBRARY MPI_INCLUDE_PATH )
2008-03-31 18:55:32 +04:00
2009-10-27 19:43:50 +03:00
mark_as_advanced ( MPI_INCLUDE_PATH MPI_COMPILE_FLAGS MPI_LINK_FLAGS MPI_LIBRARY
2008-03-31 18:55:32 +04:00
M P I _ E X T R A _ L I B R A R Y )
2009-10-27 19:43:50 +03:00
# unset to cleanup namespace
2009-11-13 18:57:01 +03:00
unset ( _MPI_PACKAGE_DIR )
unset ( _MPI_PREFIX_PATH )
2009-11-13 18:52:28 +03:00
unset ( _MPI_BASE_DIR )