xmake.lua 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package("libharu")
  2. set_homepage("http://libharu.org/")
  3. set_description("libHaru is a free, cross platform, open source library for generating PDF files.")
  4. set_license("zlib")
  5. add_urls("https://github.com/libharu/libharu/archive/refs/tags/$(version).tar.gz", {version = function (version)
  6. if version:lt("2.4.0") then
  7. return "RELEASE_" .. version:gsub("%.", "_")
  8. else
  9. return version
  10. end
  11. end})
  12. add_urls("https://github.com/libharu/libharu.git")
  13. add_versions("v2.4.5", "0ed3eacf3ceee18e40b6adffbc433f1afbe3c93500291cd95f1477bffe6f24fc")
  14. add_versions("2.3.0", "8f9e68cc5d5f7d53d1bc61a1ed876add1faf4f91070dbc360d8b259f46d9a4d2")
  15. add_deps("cmake")
  16. add_deps("zlib", "libpng")
  17. if is_plat("linux", "bsd") then
  18. add_syslinks("m")
  19. end
  20. on_load("windows", function (package)
  21. if package:config("shared") then
  22. if package:check_sizeof("void*") == "4" then
  23. package:add("defines", "HPDF_DLL_CDECL")
  24. else
  25. package:add("defines", "HPDF_DLL")
  26. end
  27. end
  28. end)
  29. on_install(function (package)
  30. io.replace("src/CMakeLists.txt", "install(FILES ${addlib}", "#", {plain = true})
  31. if package:is_plat("cross", "wasm") then
  32. io.replace("cmake/modules/haru.cmake", [[message(FATAL_ERROR "Cannot find required math library")]], [[set(MATH_LIB)]], {plain = true})
  33. io.replace("src/CMakeLists.txt", "target_link_libraries (hpdf ${M_LIB})", "", {plain = true})
  34. end
  35. local configs = {"-DLIBHPDF_EXAMPLES=OFF"}
  36. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  37. table.insert(configs, "-DLIBHPDF_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
  38. table.insert(configs, "-DLIBHPDF_STATIC=" .. (package:config("shared") and "OFF" or "ON"))
  39. import("package.tools.cmake").install(package, configs)
  40. end)
  41. on_test(function (package)
  42. assert(package:has_cfuncs("HPDF_GetVersion", {includes = "hpdf.h"}))
  43. end)