xmake.lua 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package("nativefiledialog-extended")
  2. set_homepage("https://github.com/btzy/nativefiledialog-extended")
  3. set_description("Cross platform (Windows, Mac, Linux) native file dialog library with C and C++ bindings, based on mlabbe/nativefiledialog.")
  4. add_urls("https://github.com/btzy/nativefiledialog-extended/archive/refs/tags/$(version).zip",
  5. "https://github.com/btzy/nativefiledialog-extended.git")
  6. add_versions("v1.2.0", "27dc13320816392d0d9905c60645aa684784c7c2559d656b504021edd40f07ed")
  7. add_versions("v1.1.1", "7003001d36235db2c2062cd992e61c59c77a5ad3ca5e5ed8175e56502513886e")
  8. add_versions("v1.1.0", "5827d17b6bddc8881406013f419c534e8459b38f34c2f266d9c1da8a7a7464bc")
  9. add_versions("v1.0.2", "1d2c4c50fb1e3ad8caa5ad9c3df54725c3a49a6d4a21d773a20b93ebeb5780f1")
  10. add_configs("portal", {description = "Use xdg-desktop-portal instead of GTK.", default = true, type = "boolean"})
  11. if is_plat("windows") then
  12. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  13. end
  14. add_deps("cmake")
  15. if is_plat("windows") then
  16. add_syslinks("shell32", "ole32")
  17. elseif is_plat("macosx") then
  18. add_frameworks("AppKit", "UniformTypeIdentifiers")
  19. end
  20. on_load("linux", function (package)
  21. if package:config("portal") then
  22. package:add("deps", "dbus")
  23. else
  24. package:add("deps", "gtk+3")
  25. end
  26. end)
  27. on_install("windows", "macosx", "linux", function (package)
  28. local configs = {"-DNFD_BUILD_TESTS=OFF"}
  29. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  30. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  31. table.insert(configs, "-DNFD_PORTAL=" .. (package:config("portal") and "ON" or "OFF"))
  32. import("package.tools.cmake").install(package, configs)
  33. end)
  34. on_test(function (package)
  35. assert(package:check_cxxsnippets({test = [[
  36. void test() {
  37. NFD_Init();
  38. nfdchar_t *outPath = NULL;
  39. nfdfilteritem_t filterItem[2] = {{"Source code", "c,cpp,cc"}, {"Headers", "h,hpp"}};
  40. nfdresult_t result = NFD_OpenDialog(&outPath, filterItem, 2, NULL);
  41. NFD_Quit();
  42. }
  43. ]]}, {includes = "nfd.h"}))
  44. end)