From 898ee9acfdfdaf90a69522ecf6c5fb682c624d84 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Sat, 12 Aug 2017 16:22:07 -0500 Subject: [PATCH] CMake: Add a check for ADOL-C compatibility --- cmake/configure/configure_adolc.cmake | 47 +++++++++++++++++++++++++++ cmake/modules/FindADOLC.cmake | 2 +- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/cmake/configure/configure_adolc.cmake b/cmake/configure/configure_adolc.cmake index 2a075ea828..1f49003bfb 100644 --- a/cmake/configure/configure_adolc.cmake +++ b/cmake/configure/configure_adolc.cmake @@ -17,6 +17,53 @@ # 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 + #include + void print_double(const adouble &val) + { + std::cout << \"val (non-const): \" << static_cast(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}) diff --git a/cmake/modules/FindADOLC.cmake b/cmake/modules/FindADOLC.cmake index c216dc564f..e98e38644c 100644 --- a/cmake/modules/FindADOLC.cmake +++ b/cmake/modules/FindADOLC.cmake @@ -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 # -- 2.39.5