2
0

xmake.lua 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package("libtommath")
  2. set_homepage("https://www.libtom.net")
  3. set_description("LibTomMath is a free open source portable number theoretic multiple-precision integer library written entirely in C.")
  4. set_license("Unlicense")
  5. add_urls("https://github.com/libtom/libtommath/releases/download/v$(version)/ltm-$(version).tar.xz",
  6. "https://github.com/libtom/libtommath/releases/download/v$(version)/ltm-$(version).tar.xz",
  7. "https://github.com/libtom/libtommath.git")
  8. add_versions("1.3.0", "296272d93435991308eb73607600c034b558807a07e829e751142e65ccfa9d08")
  9. if is_plat("mingw") and is_subhost("msys") then
  10. add_extsources("pacman::libtommath")
  11. elseif is_plat("linux") then
  12. add_extsources("pacman::libtommath", "apt::libtommath-dev")
  13. elseif is_plat("macosx") then
  14. add_extsources("brew::libtommath")
  15. end
  16. add_deps("cmake")
  17. add_includedirs("include", "include/libtommath")
  18. on_install(function (package)
  19. local configs = {}
  20. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  21. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  22. table.insert(configs, "-DCOMPILE_LTO =" .. (package:config("lto") and "ON" or "OFF"))
  23. if package:is_plat("windows") and package:config("shared") then
  24. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  25. end
  26. import("package.tools.cmake").install(package, configs)
  27. os.trymv(package:installdir("include/*.h"), package:installdir("include/libtommath"))
  28. end)
  29. on_test(function (package)
  30. assert(package:has_cfuncs("mp_init", {includes = "tommath.h"}))
  31. assert(package:has_cfuncs("mp_init", {includes = "libtommath/tommath.h"}))
  32. end)