xmake.lua 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package("cpp-mcp")
  2. set_homepage("https://github.com/hkr04/cpp-mcp")
  3. set_description("Lightweight C++ MCP (Model Context Protocol) SDK")
  4. set_license("MIT")
  5. add_urls("https://github.com/hkr04/cpp-mcp.git")
  6. add_versions("2025.05.24", "86856a2fcc038e05675f0649e51cd4f9d3692263")
  7. add_patches("2025.05.24", "patches/2025.05.24/install.diff", "81944d0bd25899834876f5f4cf99d10f8f45fb8d31dd7838d6500c08956d5941")
  8. add_configs("openssl", {description = "Enable openssl", default = false, type = "boolean"})
  9. add_deps("cmake")
  10. add_deps("pkgconf")
  11. add_deps("base64-terrakuh", "cpp-httplib", "nlohmann_json")
  12. if is_plat("linux", "bsd") then
  13. add_syslinks("pthread")
  14. elseif is_plat("windows", "mingw") then
  15. add_syslinks("ws2_32")
  16. end
  17. if on_check then
  18. on_check("android", function (package)
  19. local ndk = package:toolchain("ndk")
  20. local ndk_sdkver = ndk:config("ndk_sdkver")
  21. assert(ndk_sdkver and tonumber(ndk_sdkver) >= 24, "package(cpp-mcp): need ndk api level >= 24 for android")
  22. end)
  23. end
  24. on_load(function (package)
  25. if package:config("openssl") then
  26. package:add("deps", "openssl3")
  27. end
  28. end)
  29. on_install(function (package)
  30. os.rm("common")
  31. os.cp("include", package:installdir())
  32. local configs = {}
  33. if package:is_plat("windows") and package:config("shared") then
  34. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  35. end
  36. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  37. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  38. table.insert(configs, "-DMCP_SSL=" .. (package:config("openssl") and "ON" or "OFF"))
  39. import("package.tools.cmake").install(package, configs)
  40. end)
  41. on_test(function (package)
  42. assert(package:check_cxxsnippets({test = [[
  43. #include "mcp_server.h"
  44. void test() {
  45. mcp::server server("localhost", 8080);
  46. server.set_server_info("MCP Example Server", "0.1.0");
  47. }
  48. ]]}, {configs = {languages = "c++17"}}))
  49. end)