xmake.lua 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package("rmlui")
  2. set_homepage("https://mikke89.github.io/RmlUiDoc/")
  3. set_description("RmlUi is the C++ user interface library based on the HTML and CSS standards.")
  4. set_license("MIT")
  5. add_urls("https://github.com/mikke89/RmlUi/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/mikke89/RmlUi.git")
  7. add_versions("6.0", "aba3d4b8691076750eee6bf52d722db7880dfe74c18aebd8c6d676e43175fb78")
  8. add_versions("5.1", "0d28177118f0777e42864b2b7ddfc2937e81eb0dc4c52fc034c71a0c93516626")
  9. add_versions("5.0", "1f6eac0e140c35275df32088579fc3a0087fa523082c21c28d5066bd6d18882a")
  10. add_configs("freetype", {description = "Building with the default FreeType font engine.", default = true, type = "boolean"})
  11. add_configs("lua", {description = "Build Lua bindings.", default = false, type = "boolean"})
  12. add_configs("rtti", {description = "Build with rtti and exceptions enabled.", default = true, type = "boolean"})
  13. add_configs("svg", {description = "Build with SVG plugin enabled.", default = false, type = "boolean"})
  14. add_configs("lottie", {description = "Build with Lottie plugin enabled.", default = false, type = "boolean"})
  15. if is_plat("windows") then
  16. add_syslinks("shlwapi", "imm32", "user32")
  17. elseif is_plat("macosx") then
  18. add_frameworks("Cocoa")
  19. end
  20. add_deps("cmake")
  21. on_load("windows", "macosx", "linux", function (package)
  22. if not package:config("shared") then
  23. package:add("defines", "RMLUI_STATIC_LIB")
  24. end
  25. if package:config("freetype") then
  26. package:add("deps", "freetype", "zlib")
  27. end
  28. if package:config("lua") then
  29. package:add("deps", "lua")
  30. end
  31. if package:config("svg") then
  32. package:add("deps", "lunasvg")
  33. end
  34. if package:config("lottie") then
  35. package:add("deps", "rlottie")
  36. end
  37. end)
  38. on_install("windows", "macosx", "linux", function (package)
  39. if package:is_plat("linux") then
  40. io.replace("Include/RmlUi/Core/Types.h", "#include <cstdlib>", "#include <cstdlib>\n#include <cstdint>\n", {plain = true})
  41. end
  42. local configs = {"-DBUILD_TESTING=OFF", "-DBUILD_SAMPLES=OFF"}
  43. if package:is_plat("macosx") and package:is_arch("arm64") then
  44. table.insert(configs, "-DCMAKE_OSX_ARCHITECTURES=arm64")
  45. end
  46. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  47. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  48. table.insert(configs, "-DNO_FONT_INTERFACE_DEFAULT=" .. (package:config("freetype") and "OFF" or "ON"))
  49. table.insert(configs, "-DBUILD_LUA_BINDINGS=" .. (package:config("lua") and "ON" or "OFF"))
  50. table.insert(configs, "-DENABLE_SVG_PLUGIN=" .. (package:config("svg") and "ON" or "OFF"))
  51. table.insert(configs, "-DENABLE_LOTTIE_PLUGIN=" .. (package:config("lottie") and "ON" or "OFF"))
  52. table.insert(configs, "-DDISABLE_RTTI_AND_EXCEPTIONS=" .. (package:config("rtti") and "OFF" or "ON"))
  53. if package:config("freetype") then
  54. import("package.tools.cmake").install(package, configs, {packagedeps = {"zlib"}})
  55. else
  56. import("package.tools.cmake").install(package, configs)
  57. end
  58. end)
  59. on_test(function (package)
  60. assert(package:check_cxxsnippets({test = [[
  61. #include <RmlUi/Core.h>
  62. void test() {
  63. Rml::Context* context = Rml::CreateContext("default", Rml::Vector2i(640, 480));
  64. }
  65. ]]}, {configs = {languages = "c++14"}}))
  66. end)