xmake.lua 1.6 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package("magic_enum")
  2. set_kind("library", {headeronly = true})
  3. set_homepage("https://github.com/Neargye/magic_enum")
  4. set_description("Static reflection for enums (to string, from string, iteration) for modern C++, work with any enum type without any macro or boilerplate code")
  5. set_license("MIT")
  6. add_urls("https://github.com/Neargye/magic_enum/archive/refs/tags/$(version).tar.gz",
  7. "https://github.com/Neargye/magic_enum.git")
  8. add_versions("v0.7.3", "b8d0cd848546fee136dc1fa4bb021a1e4dc8fe98e44d8c119faa3ef387636bf7")
  9. add_versions("v0.8.0", "5e7680e877dd4cf68d9d0c0e3c2a683b432a9ba84fc1993c4da3de70db894c3c")
  10. add_versions("v0.8.1", "6b948d1680f02542d651fc82154a9e136b341ce55c5bf300736b157e23f9df11")
  11. add_versions("v0.8.2", "62bd7034bbbfc3d7806001767d5775ab42f3ff33bb38366e1ceb21102f0dff9a")
  12. add_deps("cmake")
  13. on_install(function (package)
  14. local configs = {
  15. "-DMAGIC_ENUM_OPT_BUILD_EXAMPLES=OFF",
  16. "-DMAGIC_ENUM_OPT_BUILD_TESTS=OFF",
  17. "-DMAGIC_ENUM_OPT_INSTALL=ON"
  18. }
  19. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  20. import("package.tools.cmake").install(package, configs)
  21. end)
  22. on_test(function (package)
  23. assert(package:check_cxxsnippets({test = [[
  24. enum class Color { RED = 2, BLUE = 4, GREEN = 8 };
  25. void test() {
  26. Color color = Color::RED;
  27. auto color_name = magic_enum::enum_name(color);
  28. }
  29. ]]}, {configs = {languages = "c++17"}, includes = "magic_enum.hpp"}))
  30. end)