xmake.lua 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package("libjuice")
  2. set_homepage("https://github.com/paullouisageneau/libjuice")
  3. set_description("JUICE is a UDP Interactive Connectivity Establishment library")
  4. set_license("MPL-2.0")
  5. add_urls("https://github.com/paullouisageneau/libjuice/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/paullouisageneau/libjuice.git")
  7. add_versions("v1.6.2", "5078176d55042f3ccf3999c2556d84903f7edf80177ce4a7bf59507541e93938")
  8. add_versions("v1.6.1", "14d7cfc1a541843c1678828ad52d860d043bd82ed39ff076b260565796e4e4ee")
  9. add_configs("nettle", {description = "Use Nettle for hash functions", default = false, type = "boolean"})
  10. if is_plat("windows", "mingw") then
  11. add_syslinks("ws2_32", "bcrypt")
  12. elseif is_plat("linux", "bsd") then
  13. add_syslinks("pthread")
  14. end
  15. add_deps("cmake")
  16. on_load(function (package)
  17. if package:config("nettle") then
  18. package:add("deps", "nettle")
  19. end
  20. if not package:config("shared") and package:is_plat("windows", "mingw") then
  21. package:add("defines", "JUICE_STATIC")
  22. end
  23. end)
  24. on_install(function (package)
  25. io.replace("CMakeLists.txt", "set(CMAKE_POSITION_INDEPENDENT_CODE ON)", "", {plain = true})
  26. local configs = {
  27. "-DNO_TESTS=ON",
  28. }
  29. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  30. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  31. table.insert(configs, "-DUSE_NETTLE=" .. (package:config("nettle") and "ON" or "OFF"))
  32. import("package.tools.cmake").install(package, configs)
  33. end)
  34. on_test(function (package)
  35. assert(package:has_cfuncs("juice_create", {includes = "juice/juice.h"}))
  36. end)