xmake.lua 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package("libevent")
  2. set_homepage("https://libevent.org/")
  3. set_description("Event notification library")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://github.com/libevent/libevent/releases/download/release-$(version)-stable/libevent-$(version)-stable.tar.gz",
  6. "https://github.com/libevent/libevent.git")
  7. add_versions("2.1.12", "92e6de1be9ec176428fd2367677e61ceffc2ee1cb119035037a27d346b0403bb")
  8. add_configs("openssl", {description = "Build with OpenSSL library.", default = false, type = "boolean"})
  9. add_configs("mbedtls", {description = "Build with mbedtls library.", default = false, type = "boolean"})
  10. if is_plat("windows", "mingw") then
  11. add_syslinks("ws2_32", "advapi32", "iphlpapi")
  12. end
  13. add_deps("cmake")
  14. on_load(function (package)
  15. if package:config("openssl") then
  16. package:add("deps", "openssl3")
  17. end
  18. if package:config("mbedtls") then
  19. package:add("deps", "mbedtls")
  20. end
  21. end)
  22. on_install("!android and (!mingw or mingw|!i386)", function (package)
  23. io.replace("CMakeLists.txt", "advapi32", "advapi32 crypt32", {plain = true})
  24. if package:gitref() or package:version():eq("2.1.12") then
  25. io.replace("cmake/LibeventConfig.cmake.in",
  26. 'get_filename_component(_INSTALL_PREFIX "${LIBEVENT_CMAKE_DIR}/../../.." ABSOLUTE)',
  27. 'get_filename_component(_INSTALL_PREFIX "${LIBEVENT_CMAKE_DIR}/../.." ABSOLUTE)',
  28. {plain = true})
  29. io.replace("cmake/LibeventConfig.cmake.in", "NO_DEFAULT_PATH)", ")", {plain = true})
  30. end
  31. local configs = {
  32. "-DEVENT__DISABLE_TESTS=ON",
  33. "-DEVENT__DISABLE_REGRESS=ON",
  34. "-DEVENT__DISABLE_SAMPLES=ON",
  35. }
  36. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  37. table.insert(configs, "-DEVENT__LIBRARY_TYPE=" .. (package:config("shared") and "SHARED" or "STATIC"))
  38. table.insert(configs, "-DEVENT__DISABLE_OPENSSL=" .. (package:config("openssl") and "OFF" or "ON"))
  39. table.insert(configs, "-DEVENT__DISABLE_MBEDTLS=" .. (package:config("mbedtls") and "OFF" or "ON"))
  40. if package:is_plat("windows") then
  41. table.insert(configs, "-DEVENT__MSVC_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
  42. table.insert(configs, "-DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=''")
  43. end
  44. import("package.tools.cmake").install(package, configs)
  45. end)
  46. on_test(function (package)
  47. assert(package:has_cfuncs("event_base_new", {includes = "event2/event.h"}))
  48. end)