xmake.lua 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package("gloo")
  2. set_homepage("https://github.com/pytorch/gloo")
  3. set_description("Collective communications library with various primitives for multi-machine training.")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://github.com/pytorch/gloo.git")
  6. add_versions("2025.07.29", "1dbd7e931568a5e3d6da16c0f2058f0606039640")
  7. add_configs("mpi", {description = "Build mpi transport.", default = false, type = "boolean"})
  8. add_configs("redis", {description = "Support using Redis for rendezvous.", default = false, type = "boolean"})
  9. add_configs("libuv", {description = "Build libuv transport.", default = false, type = "boolean"})
  10. if is_plat("linux") then
  11. add_configs("openssl", {description = "Build TCP-TLS transport with OpenSSL.", default = false, values = {false, "dynlink", "dynload"}})
  12. end
  13. if is_plat("linux", "bsd") then
  14. add_syslinks("pthread")
  15. end
  16. add_deps("cmake")
  17. on_check(function (package)
  18. assert(package:is_arch64(), "Gloo can only be built on 64-bit systems.")
  19. end)
  20. on_load(function (package)
  21. if package:config("redis") then
  22. package:add("deps", "hiredis")
  23. end
  24. if package:config("libuv") then
  25. package:add("deps", "libuv")
  26. end
  27. if package:config("openssl") then
  28. package:add("deps", "openssl")
  29. end
  30. if package:config("mpi") then
  31. package:add("deps", "mpich")
  32. end
  33. end)
  34. on_install("!windows and !mingw", function (package)
  35. local configs = {}
  36. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  37. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  38. table.insert(configs, "-DUSE_REDIS=" .. (package:config("redis") and "ON" or "OFF"))
  39. table.insert(configs, "-DUSE_LIBUV=" .. (package:config("libuv") and "ON" or "OFF"))
  40. table.insert(configs, "-DUSE_MPI=" .. (package:config("mpi") and "ON" or "OFF"))
  41. local openssl = package:config("openssl")
  42. if openssl == "dynlink" then
  43. table.insert(configs, "-DUSE_TCP_OPENSSL_LINK=ON")
  44. elseif openssl == "dynload" then
  45. table.insert(configs, "-DUSE_TCP_OPENSSL_LOAD=ON")
  46. end
  47. io.replace("gloo/types.h", "#include <iostream>", "#include <iostream>\n#include <cstdint>", {plain = true})
  48. import("package.tools.cmake").install(package, configs)
  49. end)
  50. on_test(function (package)
  51. assert(package:check_cxxsnippets({test = [[
  52. void test() {
  53. gloo::rendezvous::Context ctx(1, 2, 3);
  54. }
  55. ]]}, {configs = {languages = "c++17"}, includes = "gloo/rendezvous/context.h"}))
  56. end)