xmake.lua 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package("xproperty")
  2. set_kind("library", {headeronly = true})
  3. set_homepage("https://github.com/jupyter-xeus/xproperty")
  4. set_description("Traitlets-like C++ properties and implementation of the observer pattern")
  5. set_license("BSD-3-Clause")
  6. add_urls("https://github.com/jupyter-xeus/xproperty/archive/refs/tags/$(version).tar.gz",
  7. "https://github.com/jupyter-xeus/xproperty.git")
  8. add_versions("0.13.0", "41fa0e2b292e8e6d8ab98ec618a1e22ca6ebf1ea4bb6e51d3637a4b3c1360eaf")
  9. add_versions("0.12.1", "e8fd89e8b4bfd1631189654156dc9da4f668e011f8ccf8bc3fdd723479922b18")
  10. add_versions("0.12.0", "27cbc8e441dcc515a1ebbf11bad5ef240748d32f5e1adf84deed87a1dc57a440")
  11. add_deps("cmake")
  12. add_deps("nlohmann_json", {configs = {cmake = true}})
  13. on_install(function (package)
  14. import("package.tools.cmake").install(package, {"-DCMAKE_POLICY_DEFAULT_CMP0057=NEW"})
  15. end)
  16. on_test(function (package)
  17. local test
  18. if package:version():ge("0.13.0") then
  19. test = [[
  20. #include <xproperty/xobserved.hpp>
  21. struct Foo : public xp::xobserved
  22. {
  23. XPROPERTY(double, Foo, bar);
  24. XPROPERTY(double, Foo, baz);
  25. };
  26. void test() {
  27. Foo foo;
  28. foo.observe<Foo>(foo.bar.name(), [](Foo&) {});
  29. }
  30. ]]
  31. else
  32. test = [[
  33. #include <xproperty/xobserved.hpp>
  34. struct Foo : public xp::xobserved<Foo>
  35. {
  36. XPROPERTY(double, Foo, bar);
  37. XPROPERTY(double, Foo, baz);
  38. };
  39. void test() {
  40. Foo foo;
  41. XOBSERVE(foo, bar, [](Foo& f){});
  42. }
  43. ]]
  44. end
  45. assert(package:check_cxxsnippets({test = test}, {configs = {languages = "c++17"}}))
  46. end)