xmake.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package("expresscpp")
  2. set_homepage("https://github.com/expresscpp/expresscpp.git")
  3. set_description("Fast, unopinionated, minimalist web framework for C++ Perfect for building REST APIs.")
  4. set_license("MIT")
  5. set_urls("https://github.com/expresscpp/expresscpp/archive/$(version).tar.gz",
  6. "https://github.com/expresscpp/expresscpp.git")
  7. add_versions("v0.20.0", "55f10531e4ba162ec768cf9c745ccc7b5a0930c7ad9974b268ad40246276baa8")
  8. add_patches("v0.20.0", "patches/v0.20.0/fix-build.diff", "09bc180fd8b52f0323d16f1f96bb3a07e2b2fdbe2a48a7a6731637a940d13157")
  9. add_deps("cmake")
  10. add_deps("nlohmann_json", "fmt", {configs = {cmake = true}})
  11. add_deps("boost", {configs = {asio = true}})
  12. if is_plat("linux", "bsd") then
  13. add_syslinks("pthread")
  14. elseif is_plat("windows", "mingw") then
  15. add_syslinks("ws2_32", "mswsock")
  16. end
  17. on_install("!wasm", function (package)
  18. io.replace("CMakeLists.txt", [[if(MSVC)]], [[if(MSVC)
  19. add_definitions(-DBOOST_ALL_NO_LIB)]], {plain = true})
  20. local configs = {}
  21. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  22. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  23. if package:config("shared") and package:is_plat("windows") then
  24. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  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 "expresscpp/expresscpp.hpp"
  31. void test() {
  32. auto expresscpp = std::make_shared<expresscpp::ExpressCpp>();
  33. expresscpp->Get("/", [](auto /*req*/, auto res) { res->Send("hello world!"); });
  34. constexpr uint16_t port = 3000u;
  35. expresscpp->Listen(port,[=](auto /*ec*/) { std::cout << "Listening on port " << port << std::endl; }).Run();
  36. }
  37. ]]}, {configs = {languages = "c++17"}}))
  38. end)