From aea6229c95101dc3a04a1a6103ee5c22d6b6b068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Thu, 19 Sep 2024 18:57:39 +0200 Subject: [PATCH] Make building with UMFPACK optional. Add new CMake variable `WITH_UMFPACK` which can be used to build without using any functions from the UMFPACK library. The default for this new variable is `TRUE` so there is no difference in the build configuration to before unless a user explicitly configure with, e.g., `-DWITH_UMFPACK=OFF`. This probably fixes the issue described in #578. --- CMakeLists.txt | 62 ++++++++++++++++++++++++++-------------------- fem/config.h.cmake | 2 +- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9908d346cf..8141e368ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,6 +81,7 @@ SET(WITH_MKL FALSE CACHE BOOL "Use Intel Math Kernel library") SET(WITH_Mumps FALSE CACHE BOOL "Use Mumps sparse direct solver") SET(WITH_Hypre FALSE CACHE BOOL "Use Hypre linear algebra library") SET(WITH_CHOLMOD FALSE CACHE BOOL "Use CHOLMOD linear algebra library") +SET(WITH_UMFPACK TRUE CACHE BOOL "Use UMFPACK for LU factorization") SET(WITH_ELMERGUI FALSE CACHE BOOL "Include ElmerGUI") SET(WITH_ElmerIce FALSE CACHE BOOL "Include ElmerIce") SET(WITH_XIOS FALSE CACHE BOOL "Include XIOS") @@ -629,29 +630,35 @@ IF(WITH_ElmerIce) ADD_SUBDIRECTORY(elmerice) ENDIF(WITH_ElmerIce) -IF (EXTERNAL_UMFPACK) - MESSAGE(STATUS "Using external UMFPACK instead of built-in") - FIND_PACKAGE(UMFPACK REQUIRED) - - # Check for size of "SuiteSparse_long" - INCLUDE(CheckTypeSize) - SET(old_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES}) - SET(old_CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES}) - LIST(APPEND CMAKE_REQUIRED_INCLUDES "${UMFPACK_INCLUDE_DIR}") - LIST(APPEND CMAKE_EXTRA_INCLUDE_FILES "umfpack.h") - CHECK_TYPE_SIZE("SuiteSparse_long" SIZEOF_SUITESPARSE_LONG LANGUAGE C) - SET(CMAKE_REQUIRED_INCLUDES ${old_CMAKE_REQUIRED_INCLUDES}) - SET(CMAKE_EXTRA_INCLUDE_FILES ${old_CMAKE_EXTRA_INCLUDE_FILES}) - IF (HAVE_SIZEOF_SUITESPARSE_LONG) - IF (SIZEOF_SUITESPARSE_LONG EQUAL 4) - SET(UMFPACK_LONG_FORTRAN_TYPE "C_INT32_T") - ELSE() - SET(UMFPACK_LONG_FORTRAN_TYPE "C_INT64_T") +IF (WITH_UMFPACK) + IF (EXTERNAL_UMFPACK) + MESSAGE(STATUS "Using external UMFPACK instead of built-in") + FIND_PACKAGE(UMFPACK REQUIRED) + + # Check for size of "SuiteSparse_long" + INCLUDE(CheckTypeSize) + SET(old_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES}) + SET(old_CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES}) + LIST(APPEND CMAKE_REQUIRED_INCLUDES "${UMFPACK_INCLUDE_DIR}") + LIST(APPEND CMAKE_EXTRA_INCLUDE_FILES "umfpack.h") + CHECK_TYPE_SIZE("SuiteSparse_long" SIZEOF_SUITESPARSE_LONG LANGUAGE C) + SET(CMAKE_REQUIRED_INCLUDES ${old_CMAKE_REQUIRED_INCLUDES}) + SET(CMAKE_EXTRA_INCLUDE_FILES ${old_CMAKE_EXTRA_INCLUDE_FILES}) + IF (HAVE_SIZEOF_SUITESPARSE_LONG) + IF (SIZEOF_SUITESPARSE_LONG EQUAL 4) + SET(UMFPACK_LONG_FORTRAN_TYPE "C_INT32_T") + ELSE() + SET(UMFPACK_LONG_FORTRAN_TYPE "C_INT64_T") + ENDIF() ENDIF() + ELSE() + MESSAGE(STATUS "Using built-in UMFPACK") + ADD_SUBDIRECTORY(umfpack) ENDIF() + SET(HAVE_UMFPACK ON) + MARK_AS_ADVANCED(HAVE_UMFPACK) ELSE() - MESSAGE(STATUS "Using built-in UMFPACK") - ADD_SUBDIRECTORY(umfpack) + MESSAGE(STATUS "Building without UMFPACK") ENDIF() IF(NOT DEFINED UMFPACK_LONG_FORTRAN_TYPE) # Old versions of UMFPACK before "SuiteSparse_long" was defined used "long" @@ -711,13 +718,14 @@ MESSAGE(STATUS "------------------------------------------------") MESSAGE(STATUS " BLAS library: " "${BLAS_LIBRARIES}") MESSAGE(STATUS " LAPACK library: " "${LAPACK_LIBRARIES}") MESSAGE(STATUS "------------------------------------------------") -IF(UMFPACK_FOUND) - MESSAGE(STATUS " UMFPACK library: " "${UMFPACK_LIBRARIES}") - MESSAGE(STATUS " UMFPACK headers: " "${UMFPACK_INCLUDE_DIR}") - MARK_AS_ADVANCED(HAVE_UMFPACK) - MESSAGE(STATUS "------------------------------------------------") -ELSE() - MESSAGE(STATUS " UMFPACK library: Using internal Elmer library") +IF(WITH_UMFPACK) + IF(UMFPACK_FOUND) + MESSAGE(STATUS " UMFPACK library: " "${UMFPACK_LIBRARIES}") + MESSAGE(STATUS " UMFPACK headers: " "${UMFPACK_INCLUDE_DIR}") + MESSAGE(STATUS "------------------------------------------------") + ELSE() + MESSAGE(STATUS " UMFPACK library: Using internal Elmer library") + ENDIF() ENDIF() IF(CHOLMOD_FOUND AND SPQR_FOUND) MESSAGE(STATUS " CHOLMOD library: " "${CHOLMOD_LIBRARIES}") diff --git a/fem/config.h.cmake b/fem/config.h.cmake index 67dc31e1f2..ccb47dd9a4 100644 --- a/fem/config.h.cmake +++ b/fem/config.h.cmake @@ -139,7 +139,7 @@ #define HAVE_SYS_TYPES_H /* Define if you have a UMFPACK library. */ -#define HAVE_UMFPACK +#cmakedefine HAVE_UMFPACK /* Define to the Fortran type that matches SuiteSparse_long. */ #cmakedefine UMFPACK_LONG_FORTRAN_TYPE @UMFPACK_LONG_FORTRAN_TYPE@