xmake.lua 1.6 KB

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