xmake.lua 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package("rpclib")
  2. set_homepage("http://rpclib.net")
  3. set_description("rpclib is a modern C++ msgpack-RPC server and client library")
  4. set_license("MIT")
  5. add_urls("https://github.com/rpclib/rpclib/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/rpclib/rpclib.git")
  7. add_versions("v2.3.0", "eb9e6fa65e1a79b37097397f60599b93cb443d304fbc0447c50851bc3452fdef")
  8. if is_plat("windows", "mingw") then
  9. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  10. end
  11. if is_plat("windows", "mingw") then
  12. add_syslinks("wsock32", "ws2_32")
  13. elseif is_plat("linux", "bsd") then
  14. add_syslinks("pthread")
  15. end
  16. add_deps("cmake")
  17. on_install("!windows or windows|!arm64", function (package)
  18. local configs = {}
  19. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  20. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  21. import("package.tools.cmake").install(package, configs)
  22. end)
  23. on_test(function (package)
  24. assert(package:check_cxxsnippets({test = [[
  25. #include "rpc/client.h"
  26. #include <iostream>
  27. void test() {
  28. rpc::client c("localhost", rpc::constants::DEFAULT_PORT);
  29. std::string text;
  30. while (std::getline(std::cin, text)) {
  31. if (!text.empty()) {
  32. std::string result(c.call("echo", text).as<std::string>());
  33. std::cout << "> " << result << std::endl;
  34. }
  35. }
  36. }
  37. ]]}, {configs = {languages = "c++11"}}))
  38. end)