xmake.lua 1.4 KB

123456789101112131415161718192021222324252627282930313233
  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.8.0", "5e7680e877dd4cf68d9d0c0e3c2a683b432a9ba84fc1993c4da3de70db894c3c")
  9. add_versions("v0.7.3", "b8d0cd848546fee136dc1fa4bb021a1e4dc8fe98e44d8c119faa3ef387636bf7")
  10. add_deps("cmake")
  11. on_install(function (package)
  12. local configs = {
  13. "-DMAGIC_ENUM_OPT_BUILD_EXAMPLES=OFF",
  14. "-DMAGIC_ENUM_OPT_BUILD_TESTS=OFF",
  15. "-DMAGIC_ENUM_OPT_INSTALL=ON"
  16. }
  17. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  18. import("package.tools.cmake").install(package, configs)
  19. end)
  20. on_test(function (package)
  21. assert(package:check_cxxsnippets({test = [[
  22. enum class Color { RED = 2, BLUE = 4, GREEN = 8 };
  23. void test() {
  24. Color color = Color::RED;
  25. auto color_name = magic_enum::enum_name(color);
  26. }
  27. ]]}, {configs = {languages = "c++17"}, includes = "magic_enum.hpp"}))
  28. end)