xmake.lua 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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.4", "https://github.com/zeromq/libzmq/commit/438d5d88392baffa6c2c5e0737d9de19d6686f0d.patch", "08f8068e109225ff628f9205597b917f633f02bc0be9382b06fbd98b0de2f8a0")
  11. if is_plat("linux") then
  12. add_configs("libunwind", {description = "Enable libunwind.", default = false, type = "boolean"})
  13. end
  14. if is_plat("windows") then
  15. add_deps("cmake")
  16. add_syslinks("ws2_32", "advapi32", "rpcrt4", "iphlpapi")
  17. elseif is_plat("linux") then
  18. add_syslinks("pthread")
  19. end
  20. on_load("windows", "linux", function (package)
  21. if package:is_plat("windows") and not package:config("shared") then
  22. package:add("defines", "ZMQ_STATIC")
  23. end
  24. if package:is_plat("linux") and package:config("libunwind") then
  25. package:add("deps", "libunwind")
  26. end
  27. end)
  28. on_install("windows", function (package)
  29. io.replace("CMakeLists.txt", "NOT ${CMAKE_BUILD_TYPE} MATCHES \"Debug\"", "FALSE", {plain = true})
  30. local configs = {"-DBUILD_TESTS=OFF", "-DLIBZMQ_WERROR=OFF"}
  31. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  32. table.insert(configs, "-DBUILD_STATIC=" .. (package:config("shared") and "OFF" or "ON"))
  33. table.insert(configs, "-DBUILD_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
  34. import("package.tools.cmake").install(package, configs)
  35. end)
  36. on_install("linux", "macosx|x86_64", function (package)
  37. local configs = {"--disable-dependency-tracking", "--without-docs", "--enable-libbsd=no", "--disable-Werror"}
  38. table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
  39. table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
  40. table.insert(configs, "--enable-libunwind=" .. (package:config("libunwind") and "yes" or "no"))
  41. table.insert(configs, "--libdir=" .. package:installdir("lib"))
  42. import("package.tools.autoconf").install(package, configs)
  43. end)
  44. on_test(function (package)
  45. assert(package:has_cfuncs("zmq_msg_init_size", {includes = "zmq.h"}))
  46. end)