dependencies.cmake 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. # Boost
  7. ###############################################################################
  8. find_package(Boost COMPONENTS)
  9. if (Boost_INCLUDE_DIRS)
  10. add_library(boost INTERFACE)
  11. target_include_directories(boost INTERFACE ${Boost_INCLUDE_DIRS})
  12. else ()
  13. message("-- Boost was not found; attempting to download it if we haven't already...")
  14. include(ExternalProject)
  15. ExternalProject_Add(install-Boost
  16. PREFIX ${CMAKE_BINARY_DIR}/dependencies/boost_1_68_0
  17. URL https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.tar.bz2
  18. CONFIGURE_COMMAND ""
  19. BUILD_COMMAND ""
  20. INSTALL_COMMAND ""
  21. LOG_DOWNLOAD ON
  22. )
  23. ExternalProject_Get_Property(install-Boost SOURCE_DIR)
  24. add_library(boost INTERFACE)
  25. target_include_directories(boost INTERFACE ${SOURCE_DIR})
  26. add_dependencies(boost install-Boost)
  27. unset(SOURCE_DIR)
  28. endif ()
  29. ###############################################################################
  30. # Google Benchmark
  31. ###############################################################################
  32. execute_process(
  33. COMMAND git clone https://github.com/google/benchmark.git
  34. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  35. )
  36. execute_process(
  37. COMMAND git checkout v1.2.0
  38. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/benchmark
  39. )
  40. option(BENCHMARK_ENABLE_TESTING "Enable testing of the benchmark library." OFF)
  41. add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/benchmark)
  42. ###############################################################################
  43. # Autodiff (see https://github.com/fqiang/autodiff_library)
  44. ###############################################################################
  45. add_library(autodiff_library
  46. ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/ActNode.cpp
  47. ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/BinaryOPNode.cpp
  48. ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/Edge.cpp
  49. ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/EdgeSet.cpp
  50. ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/Node.cpp
  51. ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/OPNode.cpp
  52. ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/PNode.cpp
  53. ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/Stack.cpp
  54. ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/Tape.cpp
  55. ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/UaryOPNode.cpp
  56. ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/VNode.cpp
  57. ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/autodiff.cpp
  58. )
  59. target_include_directories(autodiff_library PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library)
  60. target_compile_definitions(autodiff_library PUBLIC BOOST_ALL_NO_LIB=1)
  61. target_link_libraries(autodiff_library boost)