xmake.lua 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package("webthing-cpp")
  2. set_kind("library", {headeronly = true})
  3. set_homepage("https://github.com/bw-hro/webthing-cpp")
  4. set_description("Webthing-CPP is a modern CPP/C++17 implementation of the WebThings API.")
  5. set_license("MIT")
  6. add_urls("https://github.com/bw-hro/webthing-cpp/archive/refs/tags/$(version).tar.gz",
  7. "https://github.com/bw-hro/webthing-cpp.git")
  8. add_versions("v1.2.0", "95d527bf8e2cef9221a42519b4798fda7d0866abd7ccaf21d57a629168a94ccc")
  9. add_versions("v1.1.0", "7f32651813168b7a51f95005be626cfaf30868db134a5bf9ca491a9d07949f5a")
  10. add_configs("ssl", {description = "Build with SSL", default = true, type = "boolean"})
  11. if is_plat("windows") then
  12. add_deps("pkgconf")
  13. else
  14. add_deps("pkg-config")
  15. end
  16. add_deps("cmake", "mdns", "libuv", "zlib", "json-schema-validator")
  17. add_deps("uwebsockets", {configs = {zip = true}})
  18. add_deps("usockets", {configs = {ssl = "openssl"}})
  19. add_deps("nlohmann_json", {configs = {cmake = true}})
  20. on_load(function (package)
  21. if package:config("ssl") then
  22. package:add("deps", "openssl")
  23. end
  24. end)
  25. on_install("linux", "macosx", "windows", function (package)
  26. io.replace("CMakeLists.txt", "find_package(unofficial-uwebsockets CONFIG REQUIRED)", [[
  27. find_package(PkgConfig QUIET)
  28. pkg_check_modules(uwebsockets REQUIRED IMPORTED_TARGET uwebsockets)
  29. ]], {plain = true})
  30. io.replace("CMakeLists.txt", "unofficial::uwebsockets::uwebsockets", "PkgConfig::uwebsockets")
  31. local configs = {"-DWT_BUILD_EXAMPLES=OFF", "-DWT_BUILD_TESTS=OFF"}
  32. table.insert(configs, "-DWT_WITH_SSL=" .. (package:config("ssl") and "ON" or "OFF"))
  33. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  34. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  35. import("package.tools.cmake").install(package, configs)
  36. end)
  37. on_test(function (package)
  38. assert(package:check_cxxsnippets({test = [[
  39. using namespace bw::webthing;
  40. void test() {
  41. auto thing = make_thing("urn:gui-thing-123", "The WebThing Slot Machine", "SLOT_MACHINE_THING", "A slot machine thing with GUI");
  42. }
  43. ]]}, {configs = {languages = "c++17"}, includes = "bw/webthing/webthing.hpp"}))
  44. end)