Skip to content

Commit

Permalink
[INFRA] Accept any Google Test/Benchmark version
Browse files Browse the repository at this point in the history
  • Loading branch information
eseiler committed Aug 17, 2023
1 parent b376837 commit 212a0e3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
20 changes: 8 additions & 12 deletions test/cmake/raptor_require_benchmark.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,25 @@ cmake_minimum_required (VERSION 3.18)
macro (raptor_require_benchmark)
enable_testing ()

set (benchmark_version "1.7.1")
set (gbenchmark_git_tag "v${benchmark_version}")
set (RAPTOR_BENCHMARK_TAG "v1.8.2")

find_package (benchmark ${benchmark_version} EXACT QUIET)
find_package (benchmark QUIET)

if (NOT benchmark_FOUND)
message (STATUS "Fetching Google Benchmark ${benchmark_version}")
# Also ensure that Google Benchmark if fetched for the latest library cron, which sets the tag to "main".
if (NOT benchmark_FOUND OR "${RAPTOR_BENCHMARK_TAG}" STREQUAL "main")
message (STATUS "Fetching Google Benchmark ${RAPTOR_BENCHMARK_TAG}")

include (FetchContent)
FetchContent_Declare (gbenchmark_fetch_content
GIT_REPOSITORY "https://github.com/google/benchmark.git"
GIT_TAG "${gbenchmark_git_tag}"
GIT_TAG "${RAPTOR_BENCHMARK_TAG}"
)
option (BENCHMARK_ENABLE_TESTING "" OFF)
option (BENCHMARK_ENABLE_WERROR "" OFF)
option (BENCHMARK_ENABLE_WERROR "" OFF) # Does not apply to Debug builds.
option (BENCHMARK_ENABLE_INSTALL "" OFF)
if (RAPTOR_LTO_BUILD AND NOT RAPTOR_IS_DEBUG)
option (BENCHMARK_ENABLE_LTO "" ON)
endif ()

FetchContent_MakeAvailable (gbenchmark_fetch_content)
else ()
message (STATUS "Found Google Benchmark ${benchmark_version}")
message (STATUS " Test dependency: Google Benchmark ${benchmark_VERSION} found.")
endif ()

# NOTE: google benchmark's CMakeLists.txt already defines Shlwapi
Expand Down
14 changes: 7 additions & 7 deletions test/cmake/raptor_require_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ cmake_minimum_required (VERSION 3.18)
macro (raptor_require_test)
enable_testing ()

set (gtest_version "1.13.0")
set (gtest_git_tag "v${gtest_version}")
set (RAPTOR_GTEST_TAG "v1.13.0")

find_package (GTest ${gtest_version} EXACT QUIET)
find_package (GTest QUIET)

if (NOT GTest_FOUND)
message (STATUS "Fetching Google Test ${gtest_version}")
# Also ensure that Google Test if fetched for the latest library cron, which sets the tag to "main".
if (NOT GTest_FOUND OR "${RAPTOR_GTEST_TAG}" STREQUAL "main")
message (STATUS "Fetching Google Test ${RAPTOR_GTEST_TAG}")

include (FetchContent)
FetchContent_Declare (gtest_fetch_content
GIT_REPOSITORY "https://github.com/google/googletest.git"
GIT_TAG "${gtest_git_tag}"
GIT_TAG "${RAPTOR_GTEST_TAG}"
)
option (BUILD_GMOCK "" OFF)
option (INSTALL_GTEST "" OFF)
FetchContent_MakeAvailable (gtest_fetch_content)
else ()
message (STATUS "Found Google Test ${gtest_version}")
message (STATUS " Test dependency: Google Test ${GTest_VERSION} found.")
endif ()

if (NOT TARGET gtest_build)
Expand Down
4 changes: 2 additions & 2 deletions test/performance/bin_influence_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ static void bulk_count(benchmark::State & state, double && fpr)
auto view = query | hash_adaptor | std::views::common;
minimiser.assign(view.begin(), view.end());

auto & result = agent.bulk_count(minimiser);
benchmark::DoNotOptimize(result);
[[maybe_unused]] auto & result = agent.bulk_count(minimiser);
benchmark::ClobberMemory();
}
}
}
Expand Down

0 comments on commit 212a0e3

Please sign in to comment.