]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Check SUNDIALS version when configuring 7747/head
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sun, 24 Feb 2019 15:40:19 +0000 (16:40 +0100)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sun, 24 Feb 2019 15:44:40 +0000 (16:44 +0100)
cmake/configure/configure_sundials.cmake
cmake/modules/FindSUNDIALS.cmake
include/deal.II/base/config.h.in

index 4a67fdd8bcd754a1dcab0e788e0d8ee9bad82091..0c62c14589de7ca719285fe0bbc1238e3b239df8 100644 (file)
 # 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()
index a23e113e7fc61c49fd5f476e0b672f8ec393bd72..f7bd1a76ecca68671f00b446570fa78efb74ee14 100644 (file)
 #   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
   )
index 23690507599dcead59881a8c7b65f288b8c51fc1..65c5efa5bc3b449b810dcb8f70ce514286d72a89 100644 (file)
     (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:

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.