diff options
author | Guillaume Chatelet <gchatelet@google.com> | 2022-03-25 13:21:20 +0000 |
---|---|---|
committer | Guillaume Chatelet <gchatelet@google.com> | 2022-03-29 08:45:53 +0000 |
commit | df838dbcfa9da0c15d5115fe3e643ee032d39a79 (patch) | |
tree | e9fbc78653e53f7cc6af23da2bade1021a63c66e | |
parent | 6a01b676cfb227bf7ca8a7b6ff1b466e33a33d1f (diff) | |
download | llvm-df838dbcfa9da0c15d5115fe3e643ee032d39a79.zip llvm-df838dbcfa9da0c15d5115fe3e643ee032d39a79.tar.gz llvm-df838dbcfa9da0c15d5115fe3e643ee032d39a79.tar.bz2 |
[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
-rw-r--r-- | libc/CMakeLists.txt | 4 | ||||
-rw-r--r-- | libc/benchmarks/CMakeLists.txt | 26 |
2 files changed, 27 insertions, 3 deletions
diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt index 6ce6c14..ca9a819 100644 --- a/libc/CMakeLists.txt +++ b/libc/CMakeLists.txt @@ -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) diff --git a/libc/benchmarks/CMakeLists.txt b/libc/benchmarks/CMakeLists.txt index 0e9ec5a..c67dadf 100644 --- a/libc/benchmarks/CMakeLists.txt +++ b/libc/benchmarks/CMakeLists.txt @@ -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 |