xmake.lua 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package("enet")
  2. set_homepage("http://enet.bespin.org")
  3. set_description("Reliable UDP networking library.")
  4. set_license("MIT")
  5. add_urls("https://github.com/lsalzman/enet/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/lsalzman/enet.git")
  7. add_versions("v1.3.18", "28603c895f9ed24a846478180ee72c7376b39b4bb1287b73877e5eae7d96b0dd")
  8. add_versions("v1.3.17", "1e0b4bc0b7127a2d779dd7928f0b31830f5b3dcb7ec9588c5de70033e8d2434a")
  9. add_patches("v1.3.18", "patches/v1.3.18/cmake.patch", "8feb51d3220d04c53d93aea053db522a0429bb3a0236039a2b62d8f01a3f638b")
  10. add_patches("v1.3.17", "patches/v1.3.17/cmake.patch", "e77d2d129952443d67c1ec432de81843d72b854d25bbd6fb244b0f85804d21d1")
  11. if is_plat("mingw") and is_subhost("msys") then
  12. add_extsources("pacman::enet")
  13. elseif is_plat("linux") then
  14. add_extsources("pacman::enet", "apt::libenet-dev")
  15. elseif is_plat("macosx") then
  16. add_extsources("brew::enet")
  17. end
  18. add_deps("cmake")
  19. if is_plat("windows", "mingw") then
  20. add_syslinks("winmm", "ws2_32")
  21. end
  22. on_load("windows", "mingw", function (package)
  23. if package:config("shared") then
  24. package:add("defines", "ENET_DLL")
  25. end
  26. end)
  27. on_install(function (package)
  28. local configs = {}
  29. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  30. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  31. import("package.tools.cmake").install(package, configs)
  32. end)
  33. on_test(function (package)
  34. assert(package:has_cfuncs("enet_initialize", {includes = "enet/enet.h"}))
  35. end)