From 5ac410a54fd588740c391ec8b96138e37d26d793 Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Fri, 14 Mar 2025 19:12:43 +0100 Subject: [PATCH] Add CMake configuration and module for MUMPS library support --- cmake/configure/configure_60_mumps.cmake | 19 +++++ cmake/modules/FindDEAL_II_MUMPS.cmake | 92 ++++++++++++++++++++++++ include/deal.II/base/config.h.in | 1 + 3 files changed, 112 insertions(+) create mode 100644 cmake/configure/configure_60_mumps.cmake create mode 100644 cmake/modules/FindDEAL_II_MUMPS.cmake diff --git a/cmake/configure/configure_60_mumps.cmake b/cmake/configure/configure_60_mumps.cmake new file mode 100644 index 0000000000..a30b1338f5 --- /dev/null +++ b/cmake/configure/configure_60_mumps.cmake @@ -0,0 +1,19 @@ +## ------------------------------------------------------------------------ +## +## SPDX-License-Identifier: LGPL-2.1-or-later +## Copyright (C) 2012 - 2023 by the deal.II authors +## +## This file is part of the deal.II library. +## +## Part of the source code is dual licensed under Apache-2.0 WITH +## LLVM-exception OR LGPL-2.1-or-later. Detailed license information +## governing the source code and code contributions can be found in +## LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II. +## +## ------------------------------------------------------------------------ + +# +# Configuration for the MUMPS library: +# + +configure_feature(MUMPS) diff --git a/cmake/modules/FindDEAL_II_MUMPS.cmake b/cmake/modules/FindDEAL_II_MUMPS.cmake new file mode 100644 index 0000000000..d6f8b396b0 --- /dev/null +++ b/cmake/modules/FindDEAL_II_MUMPS.cmake @@ -0,0 +1,92 @@ +## ------------------------------------------------------------------------ +## +## SPDX-License-Identifier: LGPL-2.1-or-later +## Copyright (C) 2012 - 2022 by the deal.II authors +## +## This file is part of the deal.II library. +## +## Part of the source code is dual licensed under Apache-2.0 WITH +## LLVM-exception OR LGPL-2.1-or-later. Detailed license information +## governing the source code and code contributions can be found in +## LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II. +## +## ------------------------------------------------------------------------ + +# +# Try to find the MUMPS library +# +# This module exports +# +# MUMPS_INCLUDE_DIRS +# MUMPS_LIBRARIES +# MUMPS_LINKER_FLAGS +# MUMPS_VERSION +# MUMPS_VERSION_MAJOR +# MUMPS_VERSION_MINOR +# MUMPS_VERSION_SUBMINOR +# + +set(MUMPS_DIR "" CACHE PATH "An optional hint to a mumps directory") +set_if_empty(MUMPS_DIR "$ENV{MUMPS_DIR}") + +# +# Search for mumps: +# + +deal_ii_find_path(MUMPS_INCLUDE_DIR dmumps_c.h + HINTS ${MUMPS_DIR} + PATH_SUFFIXES mumps include/mumps include + ) + +deal_ii_find_library(DMUMPS_LIBRARY + NAMES dmumps + HINTS ${MUMPS_DIR} + PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib + ) + +deal_ii_find_library(MUMPS_COMMON_LIBRARY + NAMES mumps_common + HINTS ${MUMPS_DIR} + PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib + ) + +# +# If we can find libpord.so (or similiar), link it in as well: +# +deal_ii_find_library(PORD_LIBRARY + NAMES pord + HINTS ${MUMPS_DIR} + PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib + ) + +if(EXISTS ${MUMPS_INCLUDE_DIR}/dmumps_c.h) + file(STRINGS "${MUMPS_INCLUDE_DIR}/dmumps_c.h" MUMPS_VERSION_STRING + REGEX "#define.*MUMPS_VERSION") + string(REGEX REPLACE "^.*MUMPS_VERSION.*\"(.+)\".*" "\\1" + MUMPS_VERSION "${MUMPS_VERSION_STRING}" + ) + string(REGEX REPLACE + "([0-9]+)\\..*" "\\1" MUMPS_VERSION_MAJOR "${MUMPS_VERSION}" + ) + string(REGEX REPLACE + "^[0-9]+\\.([0-9]+).*" "\\1" MUMPS_VERSION_MINOR "${MUMPS_VERSION}" + ) + string(REGEX REPLACE + "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" MUMPS_VERSION_SUBMINOR "${MUMPS_VERSION}" + ) +endif() + +process_feature(MUMPS + LIBRARIES + REQUIRED DMUMPS_LIBRARY MUMPS_COMMON_LIBRARY SCALAPACK_LIBRARIES + OPTIONAL BLACS_LIBRARIES + OPTIONAL PORD_LIBRARY + OPTIONAL METIS_LIBRARIES MPI_Fortran_LIBRARIES + INCLUDE_DIRS + REQUIRED MUMPS_INCLUDE_DIR + LINKER_FLAGS + OPTIONAL LAPACK_LINKER_FLAGS + CLEAR + DMUMPS_LIBRARY MUMPS_COMMON_LIBRARY PORD_LIBRARY + MUMPS_INCLUDE_DIR + ) diff --git a/include/deal.II/base/config.h.in b/include/deal.II/base/config.h.in index 865ccf190a..94fcb45ff0 100644 --- a/include/deal.II/base/config.h.in +++ b/include/deal.II/base/config.h.in @@ -109,6 +109,7 @@ DEAL_II_NAMESPACE_CLOSE #cmakedefine DEAL_II_WITH_METIS #cmakedefine DEAL_II_WITH_MPI #cmakedefine DEAL_II_WITH_MUPARSER +#cmakedefine DEAL_II_WITH_MUMPS #cmakedefine DEAL_II_FEATURE_MUPARSER_BUNDLED_CONFIGURED #cmakedefine DEAL_II_WITH_OPENCASCADE #cmakedefine DEAL_II_WITH_P4EST -- 2.39.5