Use parallel version if and only if MPI is installed

This commit is contained in:
Roland Kaufmann 2013-08-07 01:12:26 +02:00
parent 7e992a2894
commit 56b910e2ce

View File

@ -15,24 +15,39 @@
# Use define_fc_func from UseFortranWrappers to write FC_FUNC to your # Use define_fc_func from UseFortranWrappers to write FC_FUNC to your
# own config.h, and declare the function dagmg using this macro. # own config.h, and declare the function dagmg using this macro.
# USE_MPI is an option that must be declared in the program
# if this is enabled, then we use the parallel version of MUMPS
# in package "libmumps-dev"; otherwise use serial version in
# "libmumps-seq-dev"
# use the same options when searching for MPI
if (AGMG_FIND_REQUIRED)
set (_required "REQUIRED")
endif ()
if (AGMG_FIND_QUIETLY)
set (_quiet "QUIET")
endif ()
# use different version of library depending on MPI or not
if (USE_MPI)
set (_seq "")
set (_par "_par")
find_package (MPI ${_required} ${_quiet})
set (_mpi_found "MPI_FOUND")
else ()
set (_seq "_seq")
set (_par "")
set (_mpi_found "")
endif ()
find_file (AGMG_SOURCES find_file (AGMG_SOURCES
dagmg.f90 dagmg${_par}.f90
PATHS ${AGMG_ROOT} PATHS ${AGMG_ROOT}
PATH_SUFFIXES SRC PATH_SUFFIXES SRC
DOC "Yvan Notay's Algebraic Multigrid Solver, Double Precision version" DOC "Yvan Notay's Algebraic Multigrid Solver, Double Precision version"
NO_DEFAULT_PATH NO_DEFAULT_PATH
) )
# USE_MPI is an option that must be declared in the program
# if this is enabled, then we use the parallel version of MUMPS
# in package "libmumps-dev"; otherwise use serial version in
# "libmumps-seq-dev"
if (USE_MPI)
set (_seq "")
else ()
set (_seq "_seq")
endif ()
# AGMG is dependent on having the MUMPS library present # AGMG is dependent on having the MUMPS library present
find_path (MUMPS_INCLUDE_DIR find_path (MUMPS_INCLUDE_DIR
dmumps_struc.h dmumps_struc.h
@ -63,6 +78,7 @@ find_package_handle_standard_args (AGMG
MUMPS_INCLUDE_DIR MUMPS_INCLUDE_DIR
MUMPS_LIBRARY MUMPS_LIBRARY
CMAKE_Fortran_COMPILER_SUPPORTS_F90 CMAKE_Fortran_COMPILER_SUPPORTS_F90
${_mpi_found}
) )
# add our own compatibility routine to link with system MUMPS # add our own compatibility routine to link with system MUMPS
@ -71,3 +87,8 @@ if (AGMG_SOURCES)
list (APPEND AGMG_INCLUDE_DIRS "${MUMPS_INCLUDE_DIR}") list (APPEND AGMG_INCLUDE_DIRS "${MUMPS_INCLUDE_DIR}")
list (APPEND AGMG_LIBRARIES "${MUMPS_LIBRARY}") list (APPEND AGMG_LIBRARIES "${MUMPS_LIBRARY}")
endif () endif ()
if (USE_MPI AND MPI_FOUND)
list (APPEND AGMG_INCLUDE_DIRS "${MPI_Fortran_INCLUDE_PATH}")
list (APPEND AGMG_LIBRARIES "${MPI_Fortran_LIBRARIES}")
endif ()