xmake.lua 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package("sol2")
  2. set_kind("library", {headeronly = true})
  3. set_homepage("https://github.com/ThePhD/sol2")
  4. set_description("A C++ library binding to Lua.")
  5. set_urls("https://github.com/ThePhD/sol2/archive/$(version).tar.gz",
  6. "https://github.com/ThePhD/sol2.git")
  7. add_versions("v3.2.3", "f74158f92996f476786be9c9e83f8275129bb1da2a8d517d050421ac160a4b9e")
  8. add_versions("v3.2.2", "141790dae0c1821dd2dbac3595433de49ba72545845efc3ec7d88de8b0a3b2da")
  9. add_versions("v3.2.1", "b10f88dc1246f74a10348faef7d2c06e2784693307df74dcd87c4641cf6a6828")
  10. add_configs("includes_lua", {description = "Should this package includes the Lua package (set to false if you're shipping a custom Lua)", default = true, type = "boolean"})
  11. if is_plat("mingw") and is_subhost("msys") then
  12. add_extsources("pacman::sol2")
  13. elseif is_plat("linux") then
  14. add_extsources("pacman::sol2")
  15. end
  16. add_deps("cmake")
  17. on_load(function (package)
  18. if package:config("includes_lua") then
  19. package:add("deps", "lua")
  20. end
  21. end)
  22. on_install(function (package)
  23. local configs = {}
  24. import("package.tools.cmake").install(package, configs)
  25. end)
  26. on_test(function (package)
  27. if package:config("includes_lua") then
  28. assert(package:check_cxxsnippets({test = [[
  29. #include <sol/sol.hpp>
  30. #include <cassert>
  31. void test() {
  32. sol::state lua;
  33. int x = 0;
  34. lua.set_function("beep", [&x]{ ++x; });
  35. lua.script("beep()");
  36. assert(x == 1);
  37. }
  38. ]]}, {configs = {languages = "c++17"}}))
  39. end
  40. end)