xmake.lua 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package("zeromq")
  2. set_homepage("https://zeromq.org/")
  3. set_description("High-performance, asynchronous messaging library")
  4. set_license("MPL-2.0")
  5. set_urls("https://github.com/zeromq/libzmq/releases/download/v$(version)/zeromq-$(version).tar.gz",
  6. "https://github.com/zeromq/libzmq.git")
  7. add_versions("4.3.5", "6653ef5910f17954861fe72332e68b03ca6e4d9c7160eb3a8de5a5a913bfab43")
  8. add_versions("4.3.2", "ebd7b5c830d6428956b67a0454a7f8cbed1de74b3b01e5c33c5378e22740f763")
  9. add_versions("4.3.4", "c593001a89f5a85dd2ddf564805deb860e02471171b3f204944857336295c3e5")
  10. add_patches("4.3.5", "patches/4.3.5/mingw.patch", "d36460c7080f928cd83f2a5752ed832cc2dd8c0ce4d8d69fc8e23f09d48f166c")
  11. add_patches("4.3.4", "https://github.com/zeromq/libzmq/commit/438d5d88392baffa6c2c5e0737d9de19d6686f0d.patch", "08f8068e109225ff628f9205597b917f633f02bc0be9382b06fbd98b0de2f8a0")
  12. if is_plat("mingw") and is_subhost("msys") then
  13. add_extsources("pacman::zeromq")
  14. elseif is_plat("linux") then
  15. add_extsources("pacman::zeromq")
  16. elseif is_plat("macosx") then
  17. add_extsources("brew::zeromq")
  18. end
  19. add_configs("openpgm", {description = "Build with support for OpenPGM", default = false, type = "boolean", readonly = true})
  20. add_configs("norm", {description = "Build with support for NORM", default = false, type = "boolean", readonly = true})
  21. add_configs("vmci", {description = "Build with support for VMware VMCI socket", default = false, type = "boolean", readonly = true})
  22. add_configs("curve", {description = "Enable CURVE security", default = false, type = "boolean"})
  23. if is_plat("linux") then
  24. add_configs("libunwind", {description = "Enable libunwind.", default = false, type = "boolean"})
  25. end
  26. if is_plat("windows", "mingw") then
  27. add_syslinks("ws2_32", "advapi32", "rpcrt4", "iphlpapi")
  28. elseif is_plat("linux", "bsd") then
  29. add_syslinks("pthread")
  30. end
  31. add_deps("cmake")
  32. on_load(function (package)
  33. if not package:config("shared") then
  34. package:add("defines", "ZMQ_STATIC")
  35. end
  36. if package:config("openpgm") then
  37. package:add("deps", "openpgm")
  38. end
  39. if package:config("norm") then
  40. package:add("deps", "norm")
  41. end
  42. if package:config("curve") then
  43. package:add("deps", "libsodium")
  44. end
  45. if package:is_plat("linux") and package:config("libunwind") then
  46. package:add("deps", "libunwind")
  47. end
  48. end)
  49. on_install(function (package)
  50. io.replace("CMakeLists.txt", "NOT ${CMAKE_BUILD_TYPE} MATCHES \"Debug\"", "FALSE", {plain = true})
  51. local configs = {
  52. "-DBUILD_TESTS=OFF",
  53. "-DLIBZMQ_WERROR=OFF",
  54. "-DWITH_DOC=OFF",
  55. "-DWITH_DOCS=OFF",
  56. "-DWITH_PERF_TOOL=OFF",
  57. "-DENABLE_CPACK=OFF",
  58. "-DENABLE_CLANG=OFF",
  59. }
  60. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  61. table.insert(configs, "-DBUILD_STATIC=" .. (package:config("shared") and "OFF" or "ON"))
  62. table.insert(configs, "-DBUILD_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
  63. table.insert(configs, "-DENABLE_ASAN=" .. (package:config("asan") and "ON" or "OFF"))
  64. if (package:is_plat("windows") and package:is_cross()) or package:is_plat("mingw") then
  65. -- hardcode win10
  66. table.insert(configs, "-DCMAKE_SYSTEM_VERSION=10.0")
  67. end
  68. table.insert(configs, "-DWITH_OPENPGM=" .. (package:config("openpgm") and "ON" or "OFF"))
  69. table.insert(configs, "-DWITH_NORM=" .. (package:config("norm") and "ON" or "OFF"))
  70. table.insert(configs, "-DWITH_VMCI=" .. (package:config("vmci") and "ON" or "OFF"))
  71. if package:is_plat("mingw") then
  72. table.insert(configs, "-DPOLLER=epoll")
  73. end
  74. local libsodium = package:dep("libsodium")
  75. if libsodium then
  76. table.insert(configs, "-DENABLE_CURVE=ON")
  77. table.insert(configs, "-DWITH_LIBSODIUM=ON")
  78. table.insert(configs, "-DWITH_LIBSODIUM_STATIC=" .. (libsodium:config("shared") and "OFF" or "ON"))
  79. else
  80. table.insert(configs, "-DENABLE_CURVE=OFF")
  81. end
  82. import("package.tools.cmake").install(package, configs)
  83. end)
  84. on_test(function (package)
  85. assert(package:has_cfuncs("zmq_msg_init_size", {includes = "zmq.h"}))
  86. end)