|
| 1 | +cmake_minimum_required(VERSION 3.19) |
| 2 | + |
| 3 | +project(adol-c |
| 4 | + VERSION 2.7.3 |
| 5 | + LANGUAGES C CXX |
| 6 | + DESCRIPTION "A Package for Automatic Differentiation of Algorithms Written in C/C++" |
| 7 | + HOMEPAGE_URL "https://github.com/coin-or/ADOL-C") |
| 8 | + |
| 9 | +add_library(adolc SHARED) |
| 10 | +add_library(adolc::adolc ALIAS adolc) |
| 11 | + |
| 12 | +target_compile_features(adolc PUBLIC cxx_std_17) |
| 13 | + |
| 14 | +# Make the version of ADOL-C available as compile definitions |
| 15 | +target_compile_definitions(adolc PRIVATE |
| 16 | + ADOLC_VERSION=${adol-c_VERSION_MAJOR} |
| 17 | + ADOLC_SUBVERSION=${adol-c_VERSION_MINOR} |
| 18 | + ADOLC_PATCHLEVEL=${adol-c_VERSION_PATCH}) |
| 19 | + |
| 20 | +# Set the public include directory containing headers that will be installed |
| 21 | +target_include_directories(adolc |
| 22 | + PUBLIC |
| 23 | + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ADOL-C/include> |
| 24 | + $<INSTALL_INTERFACE:include>) |
| 25 | + |
| 26 | +# Set an include directory for the internally used library headers. |
| 27 | +# |
| 28 | +# This includes the files uni5_for.c, fo_rev.c, and ho_rev.c. Even though |
| 29 | +# they end with .c, they are used like header files. Together with some |
| 30 | +# preprocessor trickery this is an old-fashioned way to do generic programming. |
| 31 | +target_include_directories(adolc |
| 32 | + PRIVATE |
| 33 | + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ADOL-C/src>) |
| 34 | + |
| 35 | + |
| 36 | +# handle the options |
| 37 | +# ------------------ |
| 38 | + |
| 39 | +set(UINT_TYPE uint32_t) |
| 40 | +set(REAL_TYPE double) |
| 41 | + |
| 42 | +set(ADVBRANCH "#undef ADOLC_ADVANCED_BRANCHING") |
| 43 | +set(ADTL_REFCNT "#undef USE_ADTL_REFCOUNTING") |
| 44 | +set(SPARSE_DRIVERS "#undef SPARSE_DRIVERS") |
| 45 | +set(USE_BOOST_POOL "#undef USE_BOOST_POOL") |
| 46 | + |
| 47 | +# include subdirectories for handling of includes and source files |
| 48 | +# ---------------------------------------------------------------- |
| 49 | + |
| 50 | +add_subdirectory(ADOL-C) |
| 51 | + |
| 52 | + |
| 53 | +# export the targets |
| 54 | +# ------------------ |
| 55 | + |
| 56 | +include(CMakePackageConfigHelpers) |
| 57 | +include(GNUInstallDirs) |
| 58 | + |
| 59 | +install(TARGETS adolc EXPORT adolcTargets) |
| 60 | +install(EXPORT adolcTargets |
| 61 | + FILE adolc-targets.cmake |
| 62 | + NAMESPACE adolc:: |
| 63 | + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/adolc) |
0 commit comments