xmake.lua 2.7 KB

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