[NFC][libc] Disable benchmarks when the LLVM benchmark target is not available

Fixes https://github.com/llvm/llvm-project/issues/53686

Differential Revision: https://reviews.llvm.org/D122481
This commit is contained in:
Guillaume Chatelet 2022-03-25 13:21:20 +00:00
parent 6a01b676cf
commit df838dbcfa
2 changed files with 27 additions and 3 deletions

View File

@ -161,7 +161,9 @@ if(LLVM_INCLUDE_TESTS)
add_subdirectory(fuzzing)
endif()
add_subdirectory(benchmarks)
if(LIBC_INCLUDE_BENCHMARKS)
add_subdirectory(benchmarks)
endif()
if (LIBC_INCLUDE_DOCS)
add_subdirectory(docs)

View File

@ -43,6 +43,27 @@ endfunction()
# Build Google Benchmark for libc
#==============================================================================
include(ExternalProject)
ExternalProject_Add(google-benchmark-libc
EXCLUDE_FROM_ALL ON
PREFIX google-benchmark-libc
SOURCE_DIR ${LLVM_THIRD_PARTY_DIR}/benchmark
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/google-benchmark-libc
CMAKE_CACHE_ARGS
-DBENCHMARK_ENABLE_EXCEPTIONS:BOOL=OFF
-DBENCHMARK_ENABLE_LTO:BOOL=OFF
-DBENCHMARK_ENABLE_TESTING:BOOL=OFF
-DBENCHMARK_ENABLE_WERROR:BOOL=${LLVM_ENABLE_WERROR}
-DBENCHMARK_FORCE_WERROR:BOOL=OFF
-DBENCHMARK_USE_LIBCXX:BOOL=OFF
-DCMAKE_BUILD_TYPE:STRING=RELEASE
-DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS:STRING=${BENCHMARK_LIBC_COMPILE_FLAGS}
-DCMAKE_CXX_STANDARD:STRING=14
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
)
add_custom_target(libc-benchmark-util-tests)
# libc-benchmark
@ -52,13 +73,14 @@ add_library(libc-benchmark
LibcBenchmark.cpp
LibcBenchmark.h
)
add_dependencies(libc-benchmark benchmark)
target_link_libraries(libc-benchmark
PUBLIC
benchmark
benchmark::benchmark
LLVMSupport
Threads::Threads
)
add_dependencies(libc-benchmark google-benchmark-libc)
llvm_update_compile_flags(libc-benchmark)
add_libc_benchmark_unittest(libc-benchmark-test