xmake.lua 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 v1.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")
  7. add_versions("v1.3.2", "e01f43cf0ba35efa666503c7adb2786d4a6f7fe6eb44ce5311ac4785a0ce8a98")
  8. add_versions("v1.2.0", "90c4d8ae4f56bb706120fddcc5937cd0a0360b6f39d5cd5574a5846c0f923473")
  9. add_deps("cmake")
  10. add_deps("pahomqttc")
  11. on_install("windows", "linux", "macosx", function (package)
  12. local configs = {"-DPAHO_WITH_SSL=FALSE"}
  13. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  14. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  15. if package:is_plat("windows") then
  16. local pahomqttc = package:dep("pahomqttc"):fetch()
  17. local includedirs = pahomqttc.includedirs or pahomqttc.sysincludedirs
  18. if includedirs and #includedirs > 0 then
  19. table.insert(configs, "-DPAHO_MQTT_C_INCLUDE_DIRS=" .. table.concat(includedirs, " "))
  20. end
  21. local libfiles = pahomqttc.libfiles
  22. if libfiles then
  23. table.insert(configs, "-DPAHO_MQTT_C_LIBRARIES=" .. table.concat(libfiles, " "))
  24. end
  25. end
  26. import("package.tools.cmake").install(package, configs)
  27. end)
  28. on_test(function (package)
  29. assert(package:check_cxxsnippets({test = [[
  30. #include <mqtt/client.h>
  31. void test() {
  32. mqtt::client cli{"localhost", "some_id"};
  33. cli.connect();
  34. }
  35. ]]}, {configs = {languages = "c++11"}}))
  36. end)