diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/hana/benchmark/CMakeLists.txt | |
parent | Initial commit. (diff) | |
download | ceph-upstream/16.2.11+ds.tar.xz ceph-upstream/16.2.11+ds.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/hana/benchmark/CMakeLists.txt')
-rw-r--r-- | src/boost/libs/hana/benchmark/CMakeLists.txt | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/src/boost/libs/hana/benchmark/CMakeLists.txt b/src/boost/libs/hana/benchmark/CMakeLists.txt new file mode 100644 index 000000000..212454563 --- /dev/null +++ b/src/boost/libs/hana/benchmark/CMakeLists.txt @@ -0,0 +1,91 @@ +# Copyright Louis Dionne 2013-2017 +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +############################################################################## +# Required packages, gems and caveats +############################################################################## +find_package(Ruby 2.1) +if(NOT ${RUBY_FOUND}) + message(WARNING "Ruby >= 2.1 was not found; the benchmarks will be unavailable.") + return() +endif() + +# Check for the 'ruby-progressbar' and 'tilt' gems +execute_process(COMMAND ${RUBY_EXECUTABLE} -r ruby-progressbar -r tilt -e "" + RESULT_VARIABLE __BOOST_HANA_MISSING_GEMS + OUTPUT_QUIET ERROR_QUIET) +if(${__BOOST_HANA_MISSING_GEMS}) + message(WARNING + "The 'ruby-progressbar' and/or 'tilt' gems were not found; " + "the benchmarks will be unavailable." + "Use `gem install ruby-progressbar tilt` to install the missing gems.") + return() +endif() + +# Some benchmarks depend on those libraries +find_package(MPL11) +find_package(Meta) + +include(CheckCXXCompilerFlag) +check_cxx_compiler_flag(-ftemplate-depth=-1 BOOST_HANA_HAS_FTEMPLATE_DEPTH) + +############################################################################## +# Configure the measure.rb script +############################################################################## +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/measure.in.rb #input + ${CMAKE_CURRENT_BINARY_DIR}/measure.rb #output + @ONLY) + +############################################################################## +# Add the benchmarks +############################################################################## +add_custom_target(benchmarks COMMENT "Generate all the benchmarks.") + +add_custom_target(travis_compiler_slug USES_TERMINAL + COMMAND ${CMAKE_COMMAND} -E echo "travis_compiler_slug: $<LOWER_CASE:${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}>") +add_custom_target(travis_config_slug USES_TERMINAL + COMMAND ${CMAKE_COMMAND} -E echo "travis_config_slug: $<LOWER_CASE:$<CONFIG>>") + +file(GLOB_RECURSE BOOST_HANA_BENCHMARKS *.erb.json) +foreach(benchmark IN LISTS BOOST_HANA_BENCHMARKS) + boost_hana_target_name_for(target ${benchmark} ".erb.json") + get_filename_component(directory "${benchmark}" DIRECTORY) + file(GLOB cpp_files "${directory}/*.erb.cpp") + configure_file("${benchmark}" "${CMAKE_CURRENT_BINARY_DIR}/${target}.erb.json" @ONLY) + + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${target}.measure.cpp" "") + add_executable(${target}.measure EXCLUDE_FROM_ALL "${CMAKE_CURRENT_BINARY_DIR}/${target}.measure.cpp") + target_include_directories(${target}.measure PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") + if (MPL11_FOUND) + target_include_directories(${target}.measure PRIVATE "${MPL11_INCLUDE_DIR}") + endif() + if (Meta_FOUND) + target_include_directories(${target}.measure PRIVATE "${Meta_INCLUDE_DIR}") + endif() + if (Boost_FOUND) + target_link_libraries(${target}.measure PRIVATE Boost::boost) + endif() + boost_hana_set_test_properties(${target}.measure) + if (BOOST_HANA_HAS_FTEMPLATE_DEPTH) + target_compile_options(${target}.measure PRIVATE -ftemplate-depth=-1) + endif() + set_target_properties(${target}.measure PROPERTIES RULE_LAUNCH_COMPILE "${CMAKE_CURRENT_BINARY_DIR}/measure.rb") + set_property(TARGET ${target}.measure APPEND PROPERTY INCLUDE_DIRECTORIES "${directory}") + add_custom_target(${target}.measure.run COMMAND ${target}.measure) + + add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${target}.json" + COMMAND ${RUBY_EXECUTABLE} -r tilt -r "${CMAKE_CURRENT_BINARY_DIR}/measure.rb" + -e "MEASURE_FILE = '${CMAKE_CURRENT_BINARY_DIR}/${target}.measure.cpp'" + -e "MEASURE_TARGET = '${target}.measure'" + -e "json = Tilt::ERBTemplate.new('${CMAKE_CURRENT_BINARY_DIR}/${target}.erb.json').render" + -e "File.open('${CMAKE_CURRENT_BINARY_DIR}/${target}.json', 'w') { |f| f.write(json) } " + WORKING_DIRECTORY ${directory} + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${target}.erb.json" ${cpp_files} + VERBATIM USES_TERMINAL + COMMENT "Generating dataset for ${target}" + ) + + add_custom_target(${target} DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${target}.json") + add_dependencies(benchmarks ${target}) +endforeach() |