• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright Louis Dionne 2016
2# Copyright Zach Laine 2016
3# Distributed under the Boost Software License, Version 1.0.
4# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
5
6###############################################################################
7# Boost
8###############################################################################
9find_package(Boost COMPONENTS)
10if (Boost_INCLUDE_DIRS)
11  add_library(boost INTERFACE)
12  target_include_directories(boost INTERFACE ${Boost_INCLUDE_DIRS})
13else ()
14  message("-- Boost was not found; attempting to download it if we haven't already...")
15  include(ExternalProject)
16  ExternalProject_Add(install-Boost
17    PREFIX ${CMAKE_BINARY_DIR}/dependencies/boost_1_68_0
18    URL https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.tar.bz2
19    CONFIGURE_COMMAND ""
20    BUILD_COMMAND ""
21    INSTALL_COMMAND ""
22    LOG_DOWNLOAD ON
23  )
24
25  ExternalProject_Get_Property(install-Boost SOURCE_DIR)
26  add_library(boost INTERFACE)
27  target_include_directories(boost INTERFACE ${SOURCE_DIR})
28  add_dependencies(boost install-Boost)
29  unset(SOURCE_DIR)
30endif ()
31
32set_target_properties(boost
33    PROPERTIES
34        INTERFACE_COMPILE_FEATURES cxx_decltype_auto
35        )
36
37###############################################################################
38# Google Benchmark
39###############################################################################
40
41if(YAP_BUILD_PERF)
42  execute_process(
43      COMMAND git clone https://github.com/google/benchmark.git
44      WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
45  )
46  execute_process(
47      COMMAND git checkout v1.5.0
48      WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/benchmark
49  )
50  set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
51  add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/benchmark)
52endif()
53
54
55###############################################################################
56# Autodiff (see https://github.com/fqiang/autodiff_library)
57###############################################################################
58
59if(YAP_BUILD_EXAMPLE)
60add_library(autodiff_library
61  ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/ActNode.cpp
62  ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/BinaryOPNode.cpp
63  ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/Edge.cpp
64  ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/EdgeSet.cpp
65  ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/Node.cpp
66  ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/OPNode.cpp
67  ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/PNode.cpp
68  ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/Stack.cpp
69  ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/Tape.cpp
70  ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/UaryOPNode.cpp
71  ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/VNode.cpp
72  ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/autodiff.cpp
73)
74target_include_directories(autodiff_library PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library)
75target_compile_definitions(autodiff_library PUBLIC BOOST_ALL_NO_LIB=1)
76target_link_libraries(autodiff_library boost)
77endif()
78