Fix benchmark build error when test is disabled.

This commit is contained in:
Youngjae Lee 2021-03-17 21:03:37 +09:00
parent f57513a1d6
commit 6e47230df8

View File

@ -286,9 +286,7 @@ add_executable(leveldbutil
)
target_link_libraries(leveldbutil leveldb)
if(LEVELDB_BUILD_TESTS)
enable_testing()
if(LEVELDB_BUILD_TESTS OR LEVELDB_BUILD_BENCHMARKS)
# Prevent overriding the parent project's compiler/linker settings on Windows.
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(install_gtest OFF)
@ -298,11 +296,6 @@ if(LEVELDB_BUILD_TESTS)
# This project is tested using GoogleTest.
add_subdirectory("third_party/googletest")
# This project uses Google benchmark for benchmarking.
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
set(BENCHMARK_ENABLE_EXCEPTIONS OFF CACHE BOOL "" FORCE)
add_subdirectory("third_party/benchmark")
# GoogleTest triggers a missing field initializers warning.
if(LEVELDB_HAVE_NO_MISSING_FIELD_INITIALIZERS)
set_property(TARGET gtest
@ -310,6 +303,15 @@ if(LEVELDB_BUILD_TESTS)
set_property(TARGET gmock
APPEND PROPERTY COMPILE_OPTIONS -Wno-missing-field-initializers)
endif(LEVELDB_HAVE_NO_MISSING_FIELD_INITIALIZERS)
endif(LEVELDB_BUILD_TESTS OR LEVELDB_BUILD_BENCHMARKS)
if(LEVELDB_BUILD_TESTS)
enable_testing()
# This project uses Google benchmark for benchmarking.
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
set(BENCHMARK_ENABLE_EXCEPTIONS OFF CACHE BOOL "" FORCE)
add_subdirectory("third_party/benchmark")
function(leveldb_test test_file)
get_filename_component(test_target_name "${test_file}" NAME_WE)