xmake.lua 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package("benchmark")
  2. set_homepage("https://github.com/google/benchmark")
  3. set_description("A microbenchmark support library")
  4. add_urls("https://github.com/google/benchmark/archive/v$(version).tar.gz",
  5. "https://github.com/google/benchmark.git")
  6. add_versions("1.5.2", "dccbdab796baa1043f04982147e67bb6e118fe610da2c65f88912d73987e700c")
  7. add_versions("1.5.3", "e4fbb85eec69e6668ad397ec71a3a3ab165903abe98a8327db920b94508f720e")
  8. add_versions("1.5.4", "e3adf8c98bb38a198822725c0fc6c0ae4711f16fbbf6aeb311d5ad11e5a081b5")
  9. add_versions("1.5.5", "3bff5f237c317ddfd8d5a9b96b3eede7c0802e799db520d38ce756a2a46a18a0")
  10. add_versions("1.5.6", "789f85b4810d13ff803834ea75999e41b326405d83d6a538baf01499eda96102")
  11. add_versions("1.6.0", "1f71c72ce08d2c1310011ea6436b31e39ccab8c2db94186d26657d41747c85d6")
  12. add_versions("1.6.1", "6132883bc8c9b0df5375b16ab520fac1a85dc9e4cf5be59480448ece74b278d4")
  13. if is_plat("mingw") and is_subhost("msys") then
  14. add_extsources("pacman::benchmark")
  15. elseif is_plat("linux") then
  16. add_extsources("pacman::benchmark", "apt::libbenchmark-dev")
  17. elseif is_plat("macosx")then
  18. add_extsources("brew::google-benchmark")
  19. end
  20. if is_plat("linux") then
  21. add_syslinks("pthread")
  22. elseif is_plat("windows") then
  23. add_syslinks("shlwapi")
  24. end
  25. add_deps("cmake")
  26. add_links("benchmark_main", "benchmark")
  27. on_install("macosx", "linux", "windows", function (package)
  28. local configs = {"-DBENCHMARK_ENABLE_TESTING=OFF"}
  29. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  30. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  31. import("package.tools.cmake").install(package, configs)
  32. end)
  33. on_test(function (package)
  34. assert(package:check_cxxsnippets({test = [[
  35. void BM_empty(benchmark::State& state) {
  36. for (auto _ : state) {
  37. benchmark::DoNotOptimize(state.iterations());
  38. }
  39. }
  40. BENCHMARK(BM_empty);
  41. BENCHMARK(BM_empty)->ThreadPerCpu();
  42. ]]}, {configs = {languages = "c++11"}, includes = "benchmark/benchmark.h"}))
  43. end)