From 218e6b9eeb120f08bf75e77ddae8e55a0fbd8ca2 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Sun, 24 Feb 2019 16:40:19 +0100 Subject: [PATCH] Check SUNDIALS version when configuring --- cmake/configure/configure_sundials.cmake | 28 +++++++++++ cmake/modules/FindSUNDIALS.cmake | 60 ++++++++++++++++++++++-- include/deal.II/base/config.h.in | 41 ++++++++-------- 3 files changed, 104 insertions(+), 25 deletions(-) diff --git a/cmake/configure/configure_sundials.cmake b/cmake/configure/configure_sundials.cmake index 4a67fdd8bc..0c62c14589 100644 --- a/cmake/configure/configure_sundials.cmake +++ b/cmake/configure/configure_sundials.cmake @@ -17,6 +17,34 @@ # Configuration for the SUNDIALS library: # +MACRO(FEATURE_SUNDIALS_FIND_EXTERNAL var) + FIND_PACKAGE(SUNDIALS) + + IF(SUNDIALS_FOUND) + SET(${var} TRUE) + + # + # We don't support version 4.0.0 or later yet. + # + SET(_first_unsupported_sundials_version 4.0.0) + IF(NOT SUNDIALS_VERSION VERSION_LESS ${_first_unsupported_sundials_version}) + MESSAGE(STATUS + "Insufficient SUNDIALS installation found: " + "version ${_first_unsupported_sundials_version} " + "or later is not yet supported, " + "but version ${SUNDIALS_VERSION} was found." + ) + SET(SUNDIALS_ADDITIONAL_ERROR_STRING + "Insufficient SUNDIALS installation found!\n" + "Version ${_first_unsupported_sundials_version} " + "or later is not yet supported, " + "but version ${SUNDIALS_VERSION} was found.\n" + ) + SET(${var} FALSE) + ENDIF() + ENDIF() +ENDMACRO() + MACRO(FEATURE_SUNDIALS_CONFIGURE_EXTERNAL) SET(DEAL_II_SUNDIALS_WITH_IDAS ${SUNDIALS_WITH_IDAS}) ENDMACRO() diff --git a/cmake/modules/FindSUNDIALS.cmake b/cmake/modules/FindSUNDIALS.cmake index a23e113e7f..f7bd1a76ec 100644 --- a/cmake/modules/FindSUNDIALS.cmake +++ b/cmake/modules/FindSUNDIALS.cmake @@ -21,6 +21,10 @@ # SUNDIALS_LIBRARIES # SUNDIALS_INCLUDE_DIR # SUNDIALS_WITH_IDAS +# SUNDIALS_VERSION +# SUNDIALS_VERSION_MAJOR +# SUNDIALS_VERSION_MINOR +# SUNDIALS_VERSION_PATCH # # Note that sundials headers are typically installed in several directories, # e.g., @@ -86,16 +90,64 @@ ELSE() SET(SUNDIALS_WITH_IDAS FALSE) ENDIF() +# +# Extract SUNDIALS version. +# +DEAL_II_FIND_FILE(SUNDIALS_CONFIG_H + NAMES sundials_config.h + HINTS ${SUNDIALS_INCLUDE_DIR}/sundials + ) +IF(NOT SUNDIALS_CONFIG_H MATCHES "-NOTFOUND") + FILE(STRINGS "${SUNDIALS_CONFIG_H}" SUNDIALS_VERSION_MAJOR_STRING + REGEX "#define.*SUNDIALS_VERSION_MAJOR" + ) + STRING(REGEX REPLACE "^.*SUNDIALS_VERSION_MAJOR.*([0-9]+).*" "\\1" + SUNDIALS_VERSION_MAJOR "${SUNDIALS_VERSION_MAJOR_STRING}" + ) + FILE(STRINGS "${SUNDIALS_CONFIG_H}" SUNDIALS_VERSION_MINOR_STRING + REGEX "#define.*SUNDIALS_VERSION_MINOR" + ) + STRING(REGEX REPLACE "^.*SUNDIALS_VERSION_MINOR.*([0-9]+).*" "\\1" + SUNDIALS_VERSION_MINOR "${SUNDIALS_VERSION_MINOR_STRING}" + ) + FILE(STRINGS "${SUNDIALS_CONFIG_H}" SUNDIALS_VERSION_PATCH_STRING + REGEX "#define.*SUNDIALS_VERSION_PATCH" + ) + STRING(REGEX REPLACE "^.*SUNDIALS_VERSION_PATCH.*([0-9]+).*" "\\1" + SUNDIALS_VERSION_PATCH "${SUNDIALS_VERSION_PATCH_STRING}" + ) +ENDIF() +IF(NOT "${SUNDIALS_VERSION_MAJOR}") + SET(SUNDIALS_VERSION_MAJOR "0") +ENDIF() +IF(NOT "${SUNDIALS_VERSION_MINOR}") + SET(SUNDIALS_VERSION_MINOR "0") +ENDIF() +IF(NOT "${SUNDIALS_VERSION_PATCH}") + SET(SUNDIALS_VERSION_PATCH "0") +ENDIF() +SET(SUNDIALS_VERSION + "${SUNDIALS_VERSION_MAJOR}.${SUNDIALS_VERSION_MINOR}.${SUNDIALS_VERSION_PATCH}" + ) DEAL_II_PACKAGE_HANDLE(SUNDIALS LIBRARIES REQUIRED - ${_sundials_lib_ida} SUNDIALS_LIB_ARKODE - SUNDIALS_LIB_KINSOL SUNDIALS_LIB_SER ${_sundials_lib_par} + ${_sundials_lib_ida} + SUNDIALS_LIB_ARKODE + SUNDIALS_LIB_KINSOL + SUNDIALS_LIB_SER + ${_sundials_lib_par} INCLUDE_DIRS REQUIRED SUNDIALS_INCLUDE_DIR USER_INCLUDE_DIRS REQUIRED SUNDIALS_INCLUDE_DIR CLEAR - SUNDIALS_LIB_IDA SUNDIALS_LIB_IDAS SUNDIALS_LIB_ARKODE - SUNDIALS_LIB_KINSOL SUNDIALS_LIB_SER ${_sundials_lib_par} + SUNDIALS_LIB_IDA + SUNDIALS_LIB_IDAS + SUNDIALS_LIB_ARKODE + SUNDIALS_LIB_KINSOL + SUNDIALS_LIB_SER + ${_sundials_lib_par} + SUNDIALS_INCLUDE_DIR + SUNDIALS_CONFIG_H ) diff --git a/include/deal.II/base/config.h.in b/include/deal.II/base/config.h.in index 2369050759..65c5efa5bc 100644 --- a/include/deal.II/base/config.h.in +++ b/include/deal.II/base/config.h.in @@ -245,30 +245,29 @@ (major)*1000000 + (minor)*10000 + (subminor)*100 + (patch)) #endif - /* - * SUNDIALS: - * - * Note: The following definitions will be set in sundials_config.h, - * so we don't repeat them here. - * - * SUNDIALS_VERSION_MAJOR - * SUNDIALS_VERSION_MINOR - * SUNDIALS_VERSION_PATCH - */ - - #define DEAL_II_SUNDIALS_VERSION_GTE(major,minor,subminor) \ - ((SUNDIALS_VERSION_MAJOR * 10000 + \ - SUNDIALS_VERSION_MINOR * 100 + \ - SUNDIALS_VERSION_SUBMINOR) \ +/* + * SUNDIALS: + */ + +#ifdef DEAL_II_WITH_SUNDIALS + # define DEAL_II_SUNDIALS_VERSION_MAJOR @SUNDIALS_VERSION_MAJOR@ + # define DEAL_II_SUNDIALS_VERSION_MINOR @SUNDIALS_VERSION_MINOR@ + # define DEAL_II_SUNDIALS_VERSION_PATCH @SUNDIALS_VERSION_PATCH@ + + #define DEAL_II_SUNDIALS_VERSION_GTE(major,minor,patch) \ + ((DEAL_II_SUNDIALS_VERSION_MAJOR * 10000 + \ + DEAL_II_SUNDIALS_VERSION_MINOR * 100 + \ + DEAL_II_SUNDIALS_VERSION_PATCH) \ >= \ - (major)*10000 + (minor)*100 + (subminor)) + (major)*10000 + (minor)*100 + (patch)) - #define DEAL_II_SUNDIALS_VERSION_LT(major,minor,subminor) \ - ((SUNDIALS_VERSION_MAJOR * 10000 + \ - SUNDIALS_VERSION_MINOR * 100 + \ - SUNDIALS_VERSION_SUBMINOR) \ + #define DEAL_II_SUNDIALS_VERSION_LT(major,minor,patch) \ + ((DEAL_II_SUNDIALS_VERSION_MAJOR * 10000 + \ + DEAL_II_SUNDIALS_VERSION_MINOR * 100 + \ + DEAL_II_SUNDIALS_VERSION_PATCH) \ < \ - (major)*10000 + (minor)*100 + (subminor)) + (major)*10000 + (minor)*100 + (patch)) +#endif /* * PETSc: -- 2.39.5