xmake.lua 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. package("matchit")
  2. set_kind("library", {headeronly = true})
  3. set_homepage("https://bowenfu.github.io/matchit.cpp/")
  4. set_description("A lightweight single-header pattern-matching library for C++17 with macro-free APIs.")
  5. set_license("Apache-2.0")
  6. add_urls("https://github.com/BowenFu/matchit.cpp/archive/refs/tags/$(version).tar.gz",
  7. "https://github.com/BowenFu/matchit.cpp.git")
  8. add_versions("v1.0.1", "2860cb85febf37220f75cef5b499148bafc9f5541fe1298e11b0c169bb3f31ac")
  9. add_deps("cmake")
  10. on_install(function (package)
  11. import("package.tools.cmake").install(package, {"-DBUILD_TESTING=OFF"})
  12. end)
  13. on_test(function (package)
  14. assert(package:check_cxxsnippets({test = [[
  15. constexpr int32_t gcd(int32_t a, int32_t b) {
  16. using namespace matchit;
  17. return match(a, b)(
  18. pattern | ds(_, 0) = [&] { return a >= 0 ? a : -a; },
  19. pattern | _ = [&] { return gcd(b, a%b); }
  20. );
  21. }
  22. void test() {
  23. static_assert(gcd(12, 6) == 6);
  24. }
  25. ]]}, {configs = {languages = "c++17"}, includes = "matchit.h"}))
  26. end)