xmake.lua 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package("pahomqttcpp")
  2. set_homepage("https://github.com/eclipse/paho.mqtt.cpp")
  3. set_description("Eclipse Paho MQTT C++ Client Library")
  4. set_license("EPL-2.0")
  5. add_urls("https://github.com/eclipse/paho.mqtt.cpp/archive/refs/tags/$(version).zip",
  6. "https://github.com/eclipse/paho.mqtt.cpp.git", {submodules = false})
  7. add_versions("v1.5.0", "0805f9d8003b80d3d389930bfb8d369c56cdea402effa76b6c1c61ba5aa0d804")
  8. add_versions("v1.4.1", "a3b2782ef6d19ff2ac4c6cfe29de79d8888f75122deb361ae91ca3d3a14456ee")
  9. add_versions("v1.4.0", "c165960f64322de21697eb06efdca3d74cce90f45ff5ff0efdd968708e13ba0c")
  10. add_versions("v1.3.2", "e01f43cf0ba35efa666503c7adb2786d4a6f7fe6eb44ce5311ac4785a0ce8a98")
  11. add_versions("v1.2.0", "90c4d8ae4f56bb706120fddcc5937cd0a0360b6f39d5cd5574a5846c0f923473")
  12. add_configs("openssl", {description = "Flag that defines whether to build ssl-enabled binaries too.", default = false, type = "boolean"})
  13. add_deps("cmake")
  14. on_load(function (package)
  15. if package:config("openssl") then
  16. package:add("deps", "openssl")
  17. end
  18. local opt = {configs = {asynchronous = true}}
  19. if package:config("shared") then
  20. opt.configs.shared = true
  21. if package:is_plat("windows") then
  22. package:add("defines", "PAHO_MQTTPP_IMPORTS")
  23. end
  24. end
  25. package:add("deps", "pahomqttc", opt)
  26. end)
  27. on_install("!wasm", function (package)
  28. local configs = {}
  29. local shared = package:config("shared")
  30. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  31. table.insert(configs, "-DPAHO_BUILD_SHARED=" .. (shared and "TRUE" or "FALSE"))
  32. table.insert(configs, "-DPAHO_BUILD_STATIC=" .. (shared and "FALSE" or "TRUE"))
  33. table.insert(configs, "-DPAHO_WITH_SSL=" .. (package:config("openssl") and "TRUE" or "FALSE"))
  34. import("package.tools.cmake").install(package, configs)
  35. end)
  36. on_test(function (package)
  37. local languages
  38. if package:version() and package:version():ge("1.5.0") then
  39. languages = "c++17"
  40. else
  41. languages = "c++11"
  42. end
  43. assert(package:check_cxxsnippets({test = [[
  44. #include <mqtt/client.h>
  45. void test() {
  46. mqtt::client cli{"localhost", "some_id"};
  47. cli.connect();
  48. }
  49. ]]}, {configs = {languages = languages}}))
  50. end)