1## --------------------------------------------------------------------- 2## 3## Copyright (C) 2017 - 2019 by the deal.II authors 4## 5## This file is part of the deal.II library. 6## 7## The deal.II library is free software; you can use it, redistribute 8## it, and/or modify it under the terms of the GNU Lesser General 9## Public License as published by the Free Software Foundation; either 10## version 2.1 of the License, or (at your option) any later version. 11## The full text of the license can be found in the file LICENSE.md at 12## the top level directory of deal.II. 13## 14## --------------------------------------------------------------------- 15 16# 17# Configuration for the ADOL-C library: 18# 19 20SET(FEATURE_ADOLC_AFTER BOOST TRILINOS) 21 22MACRO(FEATURE_ADOLC_FIND_EXTERNAL var) 23 FIND_PACKAGE(ADOLC) 24 25 IF(ADOLC_FOUND) 26 # 27 # So, we have a library. Let's see whether we can use it: 28 # 29 SET(${var} TRUE) 30 31 # 32 # If Adolc is configured to use the Boost allocator (of an external 33 # boost library) we must not use a bundled Boost library for deal.II. 34 # 35 IF(ADOLC_WITH_BOOST_ALLOCATOR AND FEATURE_BOOST_BUNDLED_CONFIGURED) 36 MESSAGE(STATUS 37 "Could not find a sufficient ADOL-C installation: " 38 "ADOL-C links against external Boost but deal.II was configured " 39 "with bundled Boost." 40 ) 41 SET(ADOLC_ADDITIONAL_ERROR_STRING 42 ${ADOLC_ADDITIONAL_ERROR_STRING} 43 "Could not find a sufficient ADOL-C installation:\n" 44 "ADOL-C links against external Boost but deal.II was configured " 45 "with bundled Boost.\n\n" 46 ) 47 SET(${var} FALSE) 48 ENDIF() 49 50 # 51 # We have to avoid a symbol clash with Trilinos' SEACASChaco library 52 # (the libchaco.so shared object exports the global symbol 'divide' but 53 # so does adolc itself). 54 # 55 ITEM_MATCHES(_module_found SEACASChaco ${Trilinos_PACKAGE_LIST}) 56 IF(_module_found) 57 MESSAGE(STATUS 58 "Could not find a sufficient ADOL-C installation: " 59 "Possible symbol clash between the ADOL-C library and Trilinos' SEACASChaco detected" 60 ) 61 SET(ADOLC_ADDITIONAL_ERROR_STRING 62 ${ADOLC_ADDITIONAL_ERROR_STRING} 63 "Could not find a sufficient ADOL-C installation:\n" 64 "Possible symbol clash between the ADOL-C library and Trilinos' SEACASChaco detected." 65 "If you want to use ADOL-C, please configure deal.II to use a " 66 "Trilinos library with disabled SEACASChaco.\n\n" 67 ) 68 SET(${var} FALSE) 69 ENDIF() 70 71 # 72 # We have to avoid another symbol clash with the netcdf library that 73 # might get transitively pulled in by Trilinos (the libnetcdf.so shared 74 # object exports the global symbol 'function' but so does adolc 75 # itself). 76 # 77 IF("${Trilinos_TPL_LIBRARIES}" MATCHES "netcdf") 78 MESSAGE(STATUS 79 "Could not find a sufficient ADOL-C installation: " 80 "Possible symbol clash between the ADOL-C library and netcdf " 81 "(pulled in as optional external dependency of Trilinos) detected" 82 ) 83 SET(ADOLC_ADDITIONAL_ERROR_STRING 84 ${ADOLC_ADDITIONAL_ERROR_STRING} 85 "Could not find a sufficient ADOL-C installation:\n" 86 "Possible symbol clash between the ADOL-C library and netcdf " 87 "(pulled in as optional external dependency of Trilinos). " 88 "If you want to use ADOL-C, please configure deal.II to use a " 89 "Trilinos library with disabled netcdf bindings.\n\n" 90 ) 91 SET(${var} FALSE) 92 ENDIF() 93 94 # 95 # Check whether we have a recent enough ADOL-C library that can return 96 # values from constant objects. 97 # 98 99 LIST(APPEND CMAKE_REQUIRED_LIBRARIES ${ADOLC_LIBRARIES}) 100 LIST(APPEND CMAKE_REQUIRED_INCLUDES ${ADOLC_INCLUDE_DIRS}) 101 102 CHECK_CXX_SOURCE_COMPILES(" 103 #include <adolc/adouble.h> 104 #include <iostream> 105 void print_double(const adouble &val) 106 { 107 std::cout << \"val (non-const): \" << static_cast<double>(val) << std::endl; 108 } 109 int main (int argc, char *argv[]) 110 { 111 const adouble val = 1.0; 112 print_double(val); 113 }" 114 ADOLC_DOUBLE_CAST_CHECK) 115 116 CHECK_CXX_SOURCE_COMPILES(" 117 #include <adolc/adouble.h> 118 #include <adolc/adtl.h> 119 #include <sstream> 120 int main (int argc, char *argv[]) 121 { 122 const adouble val_taped = 1.0; 123 const adtl::adouble val_tapeless = 1.0; 124 125 std::ostringstream ss; 126 ss << val_taped; 127 ss << val_tapeless; 128 }" 129 ADOLC_ADOUBLE_OSTREAM_CHECK) 130 131 RESET_CMAKE_REQUIRED() 132 133 IF(NOT ADOLC_DOUBLE_CAST_CHECK) 134 MESSAGE(STATUS 135 "Could not find a sufficient ADOL-C installation: " 136 "deal.II needs ADOL-C version 2.6.4 or newer." 137 ) 138 SET(ADOLC_ADDITIONAL_ERROR_STRING 139 ${ADOLC_ADDITIONAL_ERROR_STRING} 140 "Could not find a sufficient ADOL-C installation:\n" 141 "ADOL-C cast check failed.\n" 142 "deal.II needs ADOL-C version 2.6.4 or newer.\n\n" 143 ) 144 SET(${var} FALSE) 145 ENDIF() 146 147 IF(NOT ADOLC_ADOUBLE_OSTREAM_CHECK) 148 MESSAGE(STATUS 149 "Could not find a sufficient ADOL-C installation: " 150 "deal.II needs ADOL-C version 2.6.4 or newer." 151 ) 152 SET(ADOLC_ADDITIONAL_ERROR_STRING 153 ${ADOLC_ADDITIONAL_ERROR_STRING} 154 "Could not find a sufficient ADOL-C installation:\n" 155 "ADOL-C stream output check failed.\n" 156 "deal.II needs ADOL-C version 2.6.4 or newer.\n\n" 157 ) 158 SET(${var} FALSE) 159 ENDIF() 160 ENDIF() 161ENDMACRO() 162 163 164MACRO(FEATURE_ADOLC_CONFIGURE_EXTERNAL) 165 SET(DEAL_II_ADOLC_WITH_ADVANCED_BRANCHING ${ADOLC_WITH_ADVANCED_BRANCHING}) 166 SET(DEAL_II_ADOLC_WITH_ATRIG_ERF ${ADOLC_WITH_ATRIG_ERF}) 167 SET(DEAL_II_ADOLC_WITH_TAPELESS_REFCOUNTING ${ADOLC_WITH_TAPELESS_REFCOUNTING}) 168 SET(DEAL_II_ADOLC_WITH_BOOST_ALLOCATOR ${ADOLC_WITH_BOOST_ALLOCATOR}) 169 170 SET(DEAL_II_EXPAND_ADOLC_TYPES "adouble; adtl::adouble") 171ENDMACRO() 172 173 174CONFIGURE_FEATURE(ADOLC) 175