xmake.lua 3.5 KB

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