xmake.lua 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package("fltk")
  2. set_homepage("https://www.fltk.org")
  3. set_description("Fast Light Toolkit")
  4. add_urls("https://www.fltk.org/pub/fltk/$(version)/fltk-$(version)-source.tar.bz2", {alias = "home"})
  5. add_urls("https://github.com/fltk/fltk/archive/refs/tags/release-$(version).tar.gz", {alias = "github"})
  6. add_urls("https://github.com/fltk/fltk.git")
  7. add_versions("home:1.3.9", "103441134915402808fd45424d4061778609437e804334434e946cfd26b196c2")
  8. add_versions("github:1.3.9", "f30661851a61f1931eaaceb9ef4005584c85cb07fd7ffc38a645172b8e4eb3df")
  9. add_patches("1.3.9", "patches/1.3.9/cmake-fluid.patch", "06ee1e82a74651a0b4ba4b386e5e5436d8b95584330d02a8a2c53351210a9127")
  10. if is_plat("linux") then
  11. add_configs("pango", {description = "Use pango for font support", default = false, type = "boolean"})
  12. add_configs("xft", {description = "Use libXft for font support", default = false, type = "boolean"})
  13. end
  14. add_configs("fluid", {description = "Build fluid", default = false, type = "boolean"})
  15. add_configs("forms", {description = "Build forms", default = false, type = "boolean"})
  16. if is_plat("windows", "mingw") then
  17. add_syslinks("ws2_32", "comctl32", "gdi32", "oleaut32", "ole32", "uuid", "shell32", "advapi32", "comdlg32", "winspool", "user32", "kernel32", "odbc32")
  18. elseif is_plat("macosx") then
  19. add_frameworks("Cocoa")
  20. elseif is_plat("android") then
  21. add_syslinks("android")
  22. add_syslinks("dl")
  23. elseif is_plat("linux") then
  24. add_syslinks("dl", "pthread")
  25. add_deps("libx11", "libxext", "libxinerama", "libxcursor", "libxrender", "libxfixes", "fontconfig")
  26. end
  27. add_deps("cmake")
  28. add_deps("zlib", "libpng", "libjpeg")
  29. on_load(function (package)
  30. if package:is_plat("linux") then
  31. if package:version() and package:version():eq("1.3.9") then
  32. assert(not package:config("fluid"), "package(fltk/1.3.9): Unsupported fluid on linux")
  33. end
  34. if package:config("pango") then
  35. package:add("deps", "pango-1.0", "pangoxft-1.0", "gobject-2.0", "cairo", "pangocairo-1.0")
  36. end
  37. if package:config("xft") then
  38. package:add("deps", "libxft")
  39. end
  40. end
  41. end)
  42. on_install("windows|x86", "windows|x64", "linux", "macosx", "mingw", "msys", function (package)
  43. for _, file in ipairs(os.files("**.cxx")) do
  44. io.replace(file, "<libpng/png.h>", "<png.h>", {plain = true})
  45. end
  46. local configs = {
  47. "-DFLTK_BUILD_TEST=OFF",
  48. "-DFLTK_BUILD_EXAMPLES=OFF",
  49. "-DOPTION_USE_SYSTEM_LIBPNG=ON",
  50. "-DOPTION_USE_SYSTEM_ZLIB=ON",
  51. "-DOPTION_USE_SYSTEM_LIBJPEG=ON"
  52. }
  53. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  54. table.insert(configs, "-DOPTION_BUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  55. table.insert(configs, "-DFLTK_MSVC_RUNTIME_DLL=" .. (package:has_runtime("MD") and "ON" or "OFF"))
  56. table.insert(configs, "-DFLTK_BUILD_FLUID=" .. (package:config("fluid") and "ON" or "OFF"))
  57. table.insert(configs, "-DFLTK_BUILD_FORMS=" .. (package:config("forms") and "ON" or "OFF"))
  58. if package:is_plat("linux") then
  59. table.insert(configs, "-DOPTION_USE_PANGO=" .. (package:config("pango") and "ON" or "OFF"))
  60. table.insert(configs, "-DOPTION_USE_XFT=" .. (package:config("xft") and "ON" or "OFF"))
  61. end
  62. import("package.tools.cmake").install(package, configs)
  63. end)
  64. on_test(function (package)
  65. assert(package:check_cxxsnippets({test = [[
  66. #include "FL/Fl.H"
  67. #include "FL/Fl_Window.H"
  68. void test() {
  69. Fl_Window *win = new Fl_Window(400, 300);
  70. }
  71. ]]}, {configs = {languages = "c++11"}}))
  72. end)