Skip to content

Commit

Permalink
Make building with UMFPACK optional.
Browse files Browse the repository at this point in the history
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 ElmerCSC#578.
  • Loading branch information
mmuetzel committed Sep 19, 2024
1 parent 99c0478 commit aea6229
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 28 deletions.
62 changes: 35 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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}")
Expand Down
2 changes: 1 addition & 1 deletion fem/config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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@
Expand Down

0 comments on commit aea6229

Please sign in to comment.