xmake.lua 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package("fpng")
  2. set_homepage("https://github.com/richgel999/fpng")
  3. set_description("Super fast C++ .PNG writer/reader")
  4. add_urls("https://github.com/richgel999/fpng/archive/refs/tags/$(version).tar.gz",
  5. "https://github.com/richgel999/fpng.git")
  6. add_versions("v1.0.1", "ef4e7ee23176908fdad4936f05f3ad097abaf61485171e108fb1e7ff230bd523")
  7. add_configs("sse4", { description = "Enable SSE 4.1 support.", default = false, type = "boolean"})
  8. on_install("windows", "linux", "macosx", function (package)
  9. io.writefile("xmake.lua", [[
  10. add_rules("mode.debug", "mode.release")
  11. option("sse4", {showmenu = true, default = false})
  12. target("fpng")
  13. set_kind("$(kind)")
  14. add_files("src/fpng.cpp")
  15. add_headerfiles("src/fpng.h")
  16. if has_config("sse4") then
  17. add_defines("FPNG_NO_SSE=0")
  18. add_cxflags("-msse4.1", "-mpclmul")
  19. else
  20. add_defines("FPNG_NO_SSE=1")
  21. end
  22. if is_plat("windows") and is_kind("shared") then
  23. add_rules("utils.symbols.export_all", {export_classes = true})
  24. end
  25. ]])
  26. local configs = {sse4 = package:config("sse4")}
  27. if package:config("shared") then
  28. configs.kind = "shared"
  29. end
  30. import("package.tools.xmake").install(package, configs)
  31. end)
  32. on_test(function (package)
  33. assert(package:check_cxxsnippets({test = [[
  34. void test() {
  35. std::vector<uint8_t> fpng_file_buf;
  36. fpng::fpng_encode_image_to_memory(0, 0, 0, 0, fpng_file_buf, 0);
  37. }
  38. ]]}, {configs = {languages = "c++11"}, includes = "fpng.h"}))
  39. end)