xmake.lua 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package("clip")
  2. set_homepage("https://github.com/dacap/clip")
  3. set_description("Library to copy/retrieve content to/from the clipboard/pasteboard.")
  4. set_license("MIT")
  5. add_urls("https://github.com/dacap/clip/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/dacap/clip.git")
  7. add_versions("v1.13", "0d07f80bc48c16d049778501bfb4a58d4f5c4087fd99a53b0640d64dc3b86868")
  8. add_versions("v1.12", "54e96e04115c7ca1eeeecf432548db5cd3dddb08a91ededb118adc31b128e08c")
  9. add_versions("v1.11", "047d43f837adffcb3a26ce09fd321472615cf35a18e86418d789b70d742519dc")
  10. add_configs("image", {description = "Compile with support to copy/paste images", default = true, type = "boolean"})
  11. add_configs("list_format", {description = "Compile with support to list clipboard formats", default = false, type = "boolean"})
  12. add_configs("xp", {description = "Enable Windows XP support", default = false, type = "boolean"})
  13. add_configs("x11_png", {description = "Compile with libpng to support copy/paste image in png format", default = true, type = "boolean"})
  14. if is_plat("windows") then
  15. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  16. end
  17. add_deps("cmake")
  18. if is_plat("linux") then
  19. add_deps("libxcb")
  20. end
  21. if is_plat("windows", "mingw") then
  22. add_syslinks("advapi32", "shlwapi", "ole32", "user32", "windowscodecs", "uuid")
  23. elseif is_plat("macosx") then
  24. add_frameworks("Foundation", "AppKit", "CoreGraphics")
  25. end
  26. on_load(function(package)
  27. if package:config("image") then
  28. package:add("defines", "CLIP_ENABLE_IMAGE=1")
  29. end
  30. if package:config("list_format") then
  31. package:add("defines", "CLIP_ENABLE_LIST_FORMATS=1")
  32. end
  33. if package:is_plat("linux") and package:config("image") and package:config("x11_png") then
  34. package:add("deps", "libpng")
  35. end
  36. end)
  37. on_install("!android and !iphoneos and !bsd and !cross", function(package)
  38. io.replace("CMakeLists.txt", "ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}", "ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}\nRUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}", {plain = true})
  39. io.replace("CMakeLists.txt", "if(CLIP_WINDOWSCODECS_LIBRARY)", "if(1)", {plain = true})
  40. io.replace("CMakeLists.txt", "target_link_libraries(clip ${CLIP_WINDOWSCODECS_LIBRARY})", "target_link_libraries(clip windowscodecs)", {plain = true})
  41. local configs = {"-DCLIP_EXAMPLES=OFF", "-DCLIP_TESTS=OFF", "-DCMAKE_INSTALL_INCLUDEDIR=include/clip"}
  42. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  43. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  44. if package:config("shared") and package:is_plat("windows") then
  45. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  46. end
  47. table.insert(configs, "-DCLIP_ENABLE_IMAGE=" .. (package:config("image") and "ON" or "OFF"))
  48. table.insert(configs, "-DCLIP_ENABLE_LIST_FORMATS=" .. (package:config("list_format") and "ON" or "OFF"))
  49. table.insert(configs, "-DCLIP_SUPPORT_WINXP=" .. (package:config("xp") and "ON" or "OFF"))
  50. table.insert(configs, "-DCLIP_X11_WITH_PNG=" .. (package:config("x11_png") and "ON" or "OFF"))
  51. import("package.tools.cmake").install(package, configs)
  52. end)
  53. on_test(function(package)
  54. assert(package:check_cxxsnippets({test = [[
  55. void test() {
  56. clip::set_text("foo");
  57. }
  58. ]]}, {configs = {languages = "c++14"}, includes = {"clip/clip.h"}}))
  59. end)