• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright Peter Dimov, Hans Dembinski 2018-2019
2# Distributed under the Boost Software License, Version 1.0.
3# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
4
5# We support CMake 3.5, but prefer 3.16 policies and behavior
6cmake_minimum_required(VERSION 3.5...3.16)
7
8project(boost_histogram VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
9
10add_library(boost_histogram INTERFACE)
11add_library(Boost::histogram ALIAS boost_histogram)
12
13target_include_directories(boost_histogram INTERFACE include)
14target_compile_features(boost_histogram INTERFACE cxx_std_14)
15target_link_libraries(boost_histogram
16  INTERFACE
17    Boost::config
18    Boost::core
19    Boost::mp11
20    Boost::throw_exception
21    Boost::variant2)
22
23if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
24  # Standalone build, fetch dependencies
25
26  # Fetch support files
27
28  message(STATUS "Fetching BoostFetch.cmake")
29
30  file(DOWNLOAD
31    "https://raw.githubusercontent.com/boostorg/cmake/develop/include/BoostFetch.cmake"
32    "${CMAKE_BINARY_DIR}/BoostFetch.cmake"
33  )
34
35  include("${CMAKE_BINARY_DIR}/BoostFetch.cmake")
36
37  boost_fetch(boostorg/cmake TAG develop NO_ADD_SUBDIR)
38
39  FetchContent_GetProperties(boostorg_cmake)
40
41  list(APPEND CMAKE_MODULE_PATH ${boostorg_cmake_SOURCE_DIR}/include)
42
43  # Enable testing
44
45  include(CTest)
46  add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
47
48  if(BUILD_TESTING)
49
50    set(BUILD_TESTING OFF) # do not build tests of dependencies
51
52    boost_fetch(boostorg/assert TAG develop EXCLUDE_FROM_ALL) # needed by core
53    boost_fetch(boostorg/config TAG develop EXCLUDE_FROM_ALL)
54    boost_fetch(boostorg/core TAG develop EXCLUDE_FROM_ALL)
55    boost_fetch(boostorg/mp11 TAG develop EXCLUDE_FROM_ALL)
56    boost_fetch(boostorg/throw_exception TAG develop EXCLUDE_FROM_ALL)
57    boost_fetch(boostorg/variant2 TAG develop EXCLUDE_FROM_ALL)
58    ## No cmake support yet
59    # boost_fetch(boostorg/accumulators TAG develop)
60    # boost_fetch(boostorg/range TAG develop)
61    # boost_fetch(boostorg/serialization TAG develop)
62    # boost_fetch(boostorg/units TAG develop)
63
64    set(BUILD_TESTING ON)
65
66  endif()
67
68endif()
69
70if (BUILD_TESTING)
71
72  add_subdirectory(test)
73
74  # do not pollute the superproject with the benchmarks
75  if(NOT BOOST_SUPERPROJECT_VERSION)
76
77    add_subdirectory(benchmark)
78
79  endif()
80
81endif()
82