]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Add a check for ADOL-C compatibility
authorMatthias Maier <tamiko@43-1.org>
Sat, 12 Aug 2017 21:22:07 +0000 (16:22 -0500)
committerJean-Paul Pelteret <jppelteret@gmail.com>
Sun, 13 Aug 2017 17:00:48 +0000 (11:00 -0600)
cmake/configure/configure_adolc.cmake
cmake/modules/FindADOLC.cmake

index 2a075ea828125b27b8d3a6be35af82bba250a5d9..1f49003bfb5274077193f8ea3c58ef7bd31d4c29 100644 (file)
 # Configuration for the ADOL-C library:
 #
 
+MACRO(FEATURE_ADOLC_FIND_EXTERNAL var)
+  FIND_PACKAGE(ADOLC)
+
+  IF(ADOLC_FOUND)
+    #
+    # So, we have a library. Let's see whether we can use it:
+    #
+    SET(${var} TRUE)
+
+    #
+    # Check whether we have a recent enough ADOL-C library that can return
+    # values from constant objects.
+    #
+
+    SET(CMAKE_REQUIRED_LIBRARIES ${ADOLC_LIBRARIES})
+    SET(CMAKE_REQUIRED_INCLUDES ${ADOLC_INCLUDE_DIRS})
+    SET(CMAKE_REQUIRED_FLAGS "${DEAL_II_CXX_FLAGS}")
+    CHECK_CXX_SOURCE_COMPILES("
+      #include <adolc/adouble.h>
+      #include <iostream>
+      void print_double(const adouble &val)
+      {
+        std::cout << \"val (non-const): \" << static_cast<double>(val) << std::endl;
+      }
+      int main (int argc, char *argv[])
+      {
+        const adouble val = 1.0;
+        print_double(val);
+      }"
+      ADOLC_DOUBLE_CAST_CHECK)
+
+    IF(NOT ADOLC_DOUBLE_CAST_CHECK)
+      MESSAGE(STATUS
+        "Could not find a sufficient ADOL-C installation: "
+        "deal.II needs ADOL-C version 2.6.4 or newer."
+        )
+      SET(ADOLC_ADDITIONAL_ERROR_STRING
+        ${ADOLC_ADDITIONAL_ERROR_STRING}
+        "Could not find a sufficient ADOL-C installation:\n"
+        "ADOL-C cast check failed.\n"
+        "deal.II needs ADOL-C version 2.6.4 or newer."
+        )
+      SET(${var} FALSE)
+    ENDIF()
+  ENDIF()
+ENDMACRO()
+
 
 MACRO(FEATURE_ADOLC_CONFIGURE_EXTERNAL)
   SET(DEAL_II_ADOLC_WITH_ATRIG_ERF ${ADOLC_WITH_ATRIG_ERF})
index c216dc564ffdb5c11693153231a391d3b5d6fde7..e98e38644cdb3d454ca58c2aec97053dfe32e654 100644 (file)
@@ -16,7 +16,7 @@
 # Note: This file is adapted from https://raw.githubusercontent.com/joaoleal/CppADCodeGen/master/cmake/FindADOLC.cmake
 
 #
-# Try to find Adolc
+# Try to find Adolc
 #
 # This module exports
 #

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.