diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2020-02-15 03:09:26 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2020-02-15 03:09:26 +0000 |
commit | fa4cf8b619117872d6afddc0b97e606092eab6ee (patch) | |
tree | 872d62a700a67cef62339ab23c78fcb69ac60902 | |
parent | 340f075c1df2d7126d757b34c549ed5c51dffec6 (diff) | |
parent | 6e9b9330d4c6a1279ce715150fca8a6b7c8377c6 (diff) | |
download | google-benchmark-android11-d1-release.tar.gz |
Snap for 6210127 from 6e9b9330d4c6a1279ce715150fca8a6b7c8377c6 to rvc-d1-releaseandroid-11.0.0_r9android-11.0.0_r8android-11.0.0_r7android-11.0.0_r15android-11.0.0_r14android-11.0.0_r13android-11.0.0_r12android-11.0.0_r11android-11.0.0_r10android11-d1-s7-releaseandroid11-d1-s6-releaseandroid11-d1-s5-releaseandroid11-d1-s1-releaseandroid11-d1-release
Change-Id: I987205bc46d9aad08a87fbf250714cd1b4ca7506
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rw-r--r-- | CONTRIBUTORS | 1 | ||||
-rw-r--r-- | METADATA | 6 | ||||
-rw-r--r-- | README.md | 24 | ||||
-rw-r--r-- | src/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/commandlineflags.cc | 4 | ||||
-rw-r--r-- | test/CMakeLists.txt | 11 |
8 files changed, 42 insertions, 15 deletions
@@ -33,6 +33,7 @@ Ismael Jimenez Martinez <ismael.jimenez.martinez@gmail.com> Jern-Kuan Leong <jernkuan@gmail.com> JianXiong Zhou <zhoujianxiong2@gmail.com> Joao Paulo Magalhaes <joaoppmagalhaes@gmail.com> +Jordan Williams <jwillikers@protonmail.com> Jussi Knuuttila <jussi.knuuttila@gmail.com> Kaito Udagawa <umireon@gmail.com> Kishan Kumar <kumar.kishan@outlook.com> diff --git a/CMakeLists.txt b/CMakeLists.txt index 8cfe125..67c0b70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,7 @@ foreach(p CMP0056 # export EXE_LINKER_FLAGS to try_run CMP0057 # Support no if() IN_LIST operator CMP0063 # Honor visibility properties for all targets + CMP0077 # Allow option() overrides in importing projects ) if(POLICY ${p}) cmake_policy(SET ${p} NEW) @@ -143,8 +144,9 @@ else() add_cxx_compiler_flag(-Werror RELEASE) add_cxx_compiler_flag(-Werror RELWITHDEBINFO) add_cxx_compiler_flag(-Werror MINSIZEREL) - add_cxx_compiler_flag(-pedantic) - add_cxx_compiler_flag(-pedantic-errors) + # Disabled until googletest (gmock) stops emitting variadic macro warnings + #add_cxx_compiler_flag(-pedantic) + #add_cxx_compiler_flag(-pedantic-errors) add_cxx_compiler_flag(-Wshorten-64-to-32) add_cxx_compiler_flag(-fstrict-aliasing) # Disable warnings regarding deprecated parts of the library while building diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 04e8aa6..88f7eee 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -50,6 +50,7 @@ Jern-Kuan Leong <jernkuan@gmail.com> JianXiong Zhou <zhoujianxiong2@gmail.com> Joao Paulo Magalhaes <joaoppmagalhaes@gmail.com> John Millikin <jmillikin@stripe.com> +Jordan Williams <jwillikers@protonmail.com> Jussi Knuuttila <jussi.knuuttila@gmail.com> Kai Wolf <kai.wolf@gmail.com> Kaito Udagawa <umireon@gmail.com> @@ -9,10 +9,10 @@ third_party { type: GIT value: "https://github.com/google/benchmark.git" } - version: "5ce2429af7a8481581896afaa480552cc7584808" + version: "8982e1ee6aef31e48170400b7d1dc9969b156e5e" last_upgrade_date { year: 2020 - month: 1 - day: 8 + month: 2 + day: 7 } } @@ -178,8 +178,8 @@ BENCHMARK_MAIN(); ``` To run the benchmark, compile and link against the `benchmark` library -(libbenchmark.a/.so). If you followed the build steps above, this -library will be under the build directory you created. +(libbenchmark.a/.so). If you followed the build steps above, this library will +be under the build directory you created. ```bash # Example on linux after running the build steps above. Assumes the @@ -194,6 +194,26 @@ Alternatively, link against the `benchmark_main` library and remove The compiled executable will run all benchmarks by default. Pass the `--help` flag for option information or see the guide below. +### Usage with CMake + +If using CMake, it is recommended to link against the project-provided +`benchmark::benchmark` and `benchmark::benchmark_main` targets using +`target_link_libraries`. +It is possible to use ```find_package``` to import an installed version of the +library. +```cmake +find_package(benchmark REQUIRED) +``` +Alternatively, ```add_subdirectory``` will incorporate the library directly in +to one's CMake project. +```cmake +add_subdirectory(benchmark) +``` +Either way, link to the library as follows. +```cmake +target_link_libraries(MyTarget benchmark::benchmark) +``` + ## Platform Specific Build Instructions ### Building with GCC diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2650e3d..81c902c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,6 +18,7 @@ foreach(item ${BENCHMARK_MAIN}) endforeach() add_library(benchmark ${SOURCE_FILES}) +add_library(benchmark::benchmark ALIAS benchmark) set_target_properties(benchmark PROPERTIES OUTPUT_NAME "benchmark" VERSION ${GENERIC_LIB_VERSION} @@ -55,6 +56,7 @@ endif() # Benchmark main library add_library(benchmark_main "benchmark_main.cc") +add_library(benchmark::benchmark_main ALIAS benchmark_main) set_target_properties(benchmark_main PROPERTIES OUTPUT_NAME "benchmark_main" VERSION ${GENERIC_LIB_VERSION} @@ -64,7 +66,7 @@ set_target_properties(benchmark_main PROPERTIES target_include_directories(benchmark PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include> ) -target_link_libraries(benchmark_main benchmark) +target_link_libraries(benchmark_main benchmark::benchmark) set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated") diff --git a/src/commandlineflags.cc b/src/commandlineflags.cc index 4e60f0b..3380a12 100644 --- a/src/commandlineflags.cc +++ b/src/commandlineflags.cc @@ -217,8 +217,8 @@ bool IsTruthyFlagValue(const std::string& value) { !(v == '0' || v == 'f' || v == 'F' || v == 'n' || v == 'N'); } else if (!value.empty()) { std::string value_lower(value); - std::transform(value_lower.begin(), value_lower.end(), - value_lower.begin(), ::tolower); + std::transform(value_lower.begin(), value_lower.end(), value_lower.begin(), + [](char c) { return static_cast<char>(::tolower(c)); }); return !(value_lower == "false" || value_lower == "no" || value_lower == "off"); } else diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ddcb1a1..0d228b8 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -38,17 +38,17 @@ add_library(output_test_helper STATIC output_test_helper.cc output_test.h) macro(compile_benchmark_test name) add_executable(${name} "${name}.cc") - target_link_libraries(${name} benchmark ${CMAKE_THREAD_LIBS_INIT}) + target_link_libraries(${name} benchmark::benchmark ${CMAKE_THREAD_LIBS_INIT}) endmacro(compile_benchmark_test) macro(compile_benchmark_test_with_main name) add_executable(${name} "${name}.cc") - target_link_libraries(${name} benchmark_main) + target_link_libraries(${name} benchmark::benchmark_main) endmacro(compile_benchmark_test_with_main) macro(compile_output_test name) add_executable(${name} "${name}.cc" output_test.h) - target_link_libraries(${name} output_test_helper benchmark + target_link_libraries(${name} output_test_helper benchmark::benchmark ${BENCHMARK_CXX_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) endmacro(compile_output_test) @@ -148,7 +148,8 @@ if (BENCHMARK_HAS_CXX03_FLAG) compile_benchmark_test(cxx03_test) set_target_properties(cxx03_test PROPERTIES - COMPILE_FLAGS "-std=c++03") + CXX_STANDARD 98 + CXX_STANDARD_REQUIRED YES) # libstdc++ provides different definitions within <map> between dialects. When # LTO is enabled and -Werror is specified GCC diagnoses this ODR violation # causing the test to fail to compile. To prevent this we explicitly disable @@ -178,7 +179,7 @@ add_test(NAME complexity_benchmark COMMAND complexity_test --benchmark_min_time= if (BENCHMARK_ENABLE_GTEST_TESTS) macro(compile_gtest name) add_executable(${name} "${name}.cc") - target_link_libraries(${name} benchmark + target_link_libraries(${name} benchmark::benchmark gmock_main ${CMAKE_THREAD_LIBS_INIT}) endmacro(compile_gtest) |