xmake.lua 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package("xtd")
  2. set_homepage("https://github.com/gammasoft71/xtd")
  3. set_description("xtd is a modern C++17/20 framework to create console, GUI (forms like WinForms) and unit test applications on Microsoft Windows, Apple macOS, Linux, iOS and android (*).")
  4. set_license("MIT")
  5. add_urls("https://github.com/gammasoft71/xtd/archive/refs/tags/$(version)-beta.zip",
  6. "https://github.com/gammasoft71/xtd.git")
  7. add_versions("v0.1.2", "648f7e5e2252d0db4e9432d493cec0682c059605ae3dfded793884cbbf3d1bd5")
  8. add_configs("graphic_toolkit", {description = "Select xtd graphic toolkit.", default = "wxwidgets", type = "string", values = {"gtk3", "wxwidgets", "fltk", "gtk4", "qt5"}})
  9. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  10. -- when building the xtd shared library, it shows Cyclic dependencies error. I have summit a issue to xtd.
  11. -- https://github.com/gammasoft71/xtd/issues/264#issue-2527671013
  12. if is_plat("linux") then
  13. add_patches("v0.1.2", "patches/v0.1.2/add_wxwidgets_to_tools.patch", "3ce364859341832be2a47452a727dbabf6b368a8b11f70849fb8818de200642b")
  14. end
  15. -- regarding the problems when building with clang
  16. -- https://github.com/gammasoft71/xtd/issues/268
  17. if on_check then
  18. on_check(function (package)
  19. if package:has_tool("cxx", "clang", "clang_cl") then
  20. raise("package(xtd) unsupported clang toolchain")
  21. end
  22. end)
  23. end
  24. add_deps("cmake","alsa-lib", "xorgproto", "glib", "gsound", "libuuid")
  25. add_links("xtd", "xtd.core", "xtd.forms", "xtd.drawing", "xtd.tunit", "xtd.forms.native.wxwidgets", "xtd.3rdparty.call_stack", "xtd.core.native.unix", "xtd.drawing.native.wxwidgets")
  26. on_load("linux", function (package)
  27. if package:config("graphic_toolkit") == "wxwidgets" then
  28. package:add("deps", "wxwidgets")
  29. elseif package:config("graphic_toolkit") == "gtk3" then
  30. package:add("deps", "gtk3")
  31. elseif package:config("graphic_toolkit") == "gtk4" then
  32. package:add("deps", "gtk4")
  33. elseif package:config("graphic_toolkit") == "fltk" then
  34. package:add("deps", "fltk")
  35. elseif package:config("graphic_toolkit") == "qt5" then
  36. package:add("deps", "qt5base", "qt5core", "qt5gui", "qt5widgets")
  37. end
  38. end)
  39. on_install("linux", function (package)
  40. local configs = {" --log-level=VERBOSE", "-DXTD_NATIVE_GRAPHIC_TOOLKIT=" .. package:config("graphic_toolkit"), "-DXTD_INSTALL_RESOURCES=OFF", "-DXTD_BUILD_TOOL_SLEEPFOR_COMMAND_LINE=OFF"}
  41. table.insert(configs, "-DXTD_BUILD_SHARED_LIBRARIES=" .. (package:config("shared") and "ON" or "OFF"))
  42. table.insert(configs, "-DXTD_INSTALL_EXAMPLES=OFF")
  43. table.insert(configs, "-DXTD_BUILD_TOOL_GUIDGEN_GUI=OFF")
  44. table.insert(configs, "-DXTD_BUILD_TOOL_GUIDGEN_COMMAND_LINE=OFF")
  45. import("package.tools.cmake").install(package, configs, {packagedeps = {"libcanberra", "libuuid"}})
  46. end)
  47. on_test(function (package)
  48. assert(package:check_cxxsnippets({test = [[
  49. #include <xtd/xtd>
  50. using namespace xtd;
  51. static void test() {
  52. console::background_color(console_color::blue);
  53. console::foreground_color(console_color::white);
  54. console::write_line("Hello, World!");
  55. }
  56. ]]}, {configs = {languages = "c++20"}}))
  57. end)