diff --git a/cmake/Modules/FindAGMG.cmake b/cmake/Modules/FindAGMG.cmake index 92cf80611..caaad93a4 100644 --- a/cmake/Modules/FindAGMG.cmake +++ b/cmake/Modules/FindAGMG.cmake @@ -15,24 +15,39 @@ # Use define_fc_func from UseFortranWrappers to write FC_FUNC to your # 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 - dagmg.f90 + dagmg${_par}.f90 PATHS ${AGMG_ROOT} PATH_SUFFIXES SRC DOC "Yvan Notay's Algebraic Multigrid Solver, Double Precision version" 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 find_path (MUMPS_INCLUDE_DIR dmumps_struc.h @@ -63,6 +78,7 @@ find_package_handle_standard_args (AGMG MUMPS_INCLUDE_DIR MUMPS_LIBRARY CMAKE_Fortran_COMPILER_SUPPORTS_F90 + ${_mpi_found} ) # 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_LIBRARIES "${MUMPS_LIBRARY}") endif () + +if (USE_MPI AND MPI_FOUND) + list (APPEND AGMG_INCLUDE_DIRS "${MPI_Fortran_INCLUDE_PATH}") + list (APPEND AGMG_LIBRARIES "${MPI_Fortran_LIBRARIES}") +endif ()