xmake.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package("libgit2")
  2. set_homepage("https://libgit2.org/")
  3. set_description("A cross-platform, linkable library implementation of Git that you can use in your application.")
  4. set_license("GPL-2.0-only")
  5. set_urls("https://github.com/libgit2/libgit2/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/libgit2/libgit2.git")
  7. add_versions("v1.3.0", "192eeff84596ff09efb6b01835a066f2df7cd7985e0991c79595688e6b36444e")
  8. add_deps("cmake")
  9. if is_plat("macosx", "iphoneos") then
  10. add_frameworks("CoreFoundation", "Security")
  11. add_syslinks("iconv", "z")
  12. else
  13. add_deps("openssl", "zlib")
  14. end
  15. if is_plat("linux") then
  16. add_deps("pcre")
  17. add_syslinks("pthread", "dl")
  18. elseif is_plat("windows") then
  19. add_syslinks("ole32", "rpcrt4", "winhttp")
  20. end
  21. on_install("macosx", "linux", "windows", "android", "iphoneos", function (package)
  22. local configs = {"-DBUILD_TESTS=OFF",
  23. "-DBUILD_CLAR=OFF",
  24. "-DBUILD_EXAMPLES=OFF",
  25. "-DBUILD_FUZZERS=OFF",
  26. "-DUSE_SSH=OFF"}
  27. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  28. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  29. if package:is_plat("android", "iphoneos") then
  30. table.insert(configs, "-DUSE_HTTPS=OFF")
  31. elseif package:is_plat("windows") then
  32. if package:config("vs_runtime"):startswith("MT") then
  33. table.insert(configs, "-DSTATIC_CRT=ON")
  34. else
  35. table.insert(configs, "-DSTATIC_CRT=OFF")
  36. end
  37. io.replace("CMakeLists.txt", "/GL", "", {plain = true})
  38. end
  39. import("package.tools.cmake").install(package, configs)
  40. end)
  41. on_test(function (package)
  42. assert(package:has_cfuncs("git_repository_init", {includes = "git2.h"}))
  43. end)