1 # Copyright 2019 Hans Dembinski
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
5 cmake_minimum_required(VERSION 3.6)
7 set(CMAKE_BUILD_TYPE Release) # ok, only set in local scope
9 if (NOT COMMAND boost_fetch)
10 # `function` confuses FetchContent, sees empty CMAKE_CURRENT_LIST_DIR
11 macro(fetch_and_include name)
12 message(STATUS "Fetching ${name}")
14 set(fetch_and_include_local_path "${CMAKE_BINARY_DIR}/fetch_and_include/${name}")
15 if(NOT EXISTS ${fetch_and_include_local_path})
17 "https://raw.githubusercontent.com/boostorg/mincmake/develop/${name}"
18 "${CMAKE_BINARY_DIR}/fetch_and_include/${name}"
21 include("${CMAKE_BINARY_DIR}/fetch_and_include/${name}")
24 fetch_and_include(cmake/boost_fetch.cmake)
27 # allow benchmarks to build old versions of the code if we sit inside the boost metaproject
28 if (NOT TARGET boost_histogram)
29 add_library(boost_histogram INTERFACE)
30 add_library(Boost::histogram ALIAS boost_histogram)
31 target_compile_features(boost_histogram INTERFACE
32 cxx_alias_templates cxx_variadic_templates cxx_decltype_auto
33 cxx_defaulted_functions cxx_generic_lambdas cxx_range_for
34 cxx_relaxed_constexpr cxx_return_type_deduction)
35 target_include_directories(boost_histogram
37 ${CMAKE_CURRENT_SOURCE_DIR}/../include
38 ${CMAKE_CURRENT_SOURCE_DIR}/../../../
40 set(BENCHMARK_FLAGS) # old versions don't work with -fno-exceptions
42 set(BENCHMARK_FLAGS -fno-exceptions -fno-rtti)
45 option(BENCHMARK_ENABLE_TESTING "" OFF)
46 boost_fetch(hdembinski/benchmark)
48 macro(add_benchmark name)
49 add_executable(${name} "${name}.cpp")
50 target_compile_options(${name} PRIVATE
51 -DNDEBUG -O3 -march=native ${BENCHMARK_FLAGS} -funsafe-math-optimizations)
52 target_link_libraries(${name} PRIVATE Boost::histogram benchmark_main)
55 add_benchmark(axis_index)
56 add_benchmark(histogram_filling)
57 add_benchmark(histogram_iteration)
59 add_benchmark(histogram_parallel_filling)
64 add_benchmark(histogram_filling_gsl)
65 target_include_directories(histogram_filling_gsl PRIVATE ${GSL_INCLUDE_DIRS})
66 target_link_libraries(histogram_filling_gsl
67 PRIVATE ${GSL_LIBRARIES} benchmark_main)
70 find_package(ROOT QUIET)
72 add_benchmark(histogram_filling_root)
73 target_include_directories(histogram_filling_root PRIVATE ${ROOT_INCLUDE_DIRS})
74 target_link_libraries(histogram_filling_root
75 PRIVATE ${ROOT_LIBRARIES} benchmark_main)
76 target_compile_options(histogram_filling_root PRIVATE -frtti -fexceptions)
77 # target_link_options(histogram_filling_root
78 # PRIVATE ${ROOT_EXE_LINKER_FLAGS})