Skip to content

Commit 9cfc183

Browse files
Buristanligurio
authored andcommitted
perf: allow to provide libbenchmark for tests
This patch allows to provide the bundled libbenchmark for the performance tests from the parent project to use non-Debug build or whatsoever. Needed for tarantool/tarantool#10778 Co-authored-by: Sergey Bronnikov <[email protected]>
1 parent d118d35 commit 9cfc183

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

perf/CMakeLists.txt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,20 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
55
return()
66
endif()
77

8-
find_package(benchmark QUIET)
9-
if (NOT ${benchmark_FOUND})
10-
message(AUTHOR_WARNING "Google Benchmark submodule not found")
11-
return()
8+
# Handle a case when BENCHMARK_LIBRARIES, BENCHMARK_INCLUDE_DIRS
9+
# and benchmark_FOUND are defined in the parent project, like in
10+
# the Tarantool, that uses the bundled Benchmark library.
11+
if (NOT benchmark_FOUND)
12+
find_package(benchmark QUIET)
13+
if (NOT benchmark_FOUND)
14+
message(AUTHOR_WARNING "Google Benchmark library not found")
15+
return()
16+
endif()
17+
set(BENCHMARK_LIBRARIES benchmark::benchmark)
1218
endif()
1319

1420
include_directories("${PROJECT_SOURCE_DIR}")
1521

1622
add_executable(small.perftest small.cc)
17-
target_link_libraries(small.perftest small benchmark::benchmark)
23+
target_link_libraries(small.perftest small ${BENCHMARK_LIBRARIES})
24+
target_include_directories(small.perftest PUBLIC ${BENCHMARK_INCLUDE_DIRS})

0 commit comments

Comments
 (0)