xmake.lua 1.6 KB

123456789101112131415161718192021222324252627282930313233
  1. package("nghttp2")
  2. set_homepage("http://nghttp2.org/")
  3. set_description("nghttp2 is an implementation of HTTP/2 and its header compression algorithm HPACK in C.")
  4. set_license("MIT")
  5. add_urls("https://github.com/nghttp2/nghttp2/releases/download/v$(version)/nghttp2-$(version).tar.gz")
  6. add_versions("1.58.0", "9ebdfbfbca164ef72bdf5fd2a94a4e6dfb54ec39d2ef249aeb750a91ae361dfb")
  7. add_versions("1.46.0", "4b6d11c85f2638531d1327fe1ed28c1e386144e8841176c04153ed32a4878208")
  8. add_deps("cmake")
  9. on_load("windows", function (package)
  10. package:add("defines", "ssize_t=int")
  11. if not package:config("shared") then
  12. package:add("defines", "NGHTTP2_STATICLIB")
  13. end
  14. end)
  15. on_install("windows", "macosx", "linux", function (package)
  16. io.replace("CMakeLists.txt", "add_subdirectory(doc)", "", {plain = true})
  17. local configs = {"-DENABLE_LIB_ONLY=ON"}
  18. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  19. table.insert(configs, "-DENABLE_SHARED_LIB=" .. (package:config("shared") and "ON" or "OFF"))
  20. table.insert(configs, "-DENABLE_STATIC_LIB=" .. (package:config("shared") and "OFF" or "ON"))
  21. if package:is_plat("windows") then
  22. table.insert(configs, "-DENABLE_STATIC_CRT=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
  23. end
  24. import("package.tools.cmake").install(package, configs)
  25. end)
  26. on_test(function (package)
  27. assert(package:has_cfuncs("nghttp2_version", {includes = "nghttp2/nghttp2.h"}))
  28. end)