xmake.lua 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package("pcapplusplus")
  2. set_homepage("https://github.com/seladb/PcapPlusPlus")
  3. set_description("PcapPlusPlus is a multiplatform C++ library for capturing, parsing and crafting of network packets.")
  4. set_license("Unlicense")
  5. set_urls("https://github.com/seladb/PcapPlusPlus/archive/refs/tags/$(version).zip",
  6. "https://github.com/seladb/PcapPlusPlus.git")
  7. add_versions("v24.09", "0a9d80d09a906c08a1df5f5a937134355c7cb3fc8a599bf1a0f10002cf0285be")
  8. add_versions("v23.09", "f2b92d817df6138363be0d144a61716f8ecc43216f0008135da2e0e15727d35a")
  9. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  10. add_links("Pcap++", "Packet++", "Common++")
  11. if is_plat("windows") then
  12. add_syslinks("ws2_32")
  13. end
  14. add_deps("cmake")
  15. if is_plat("windows") then
  16. add_deps("npcap_sdk")
  17. elseif is_plat("linux") then
  18. add_deps("libpcap")
  19. end
  20. on_install("windows", "linux", function (package)
  21. local configs = {
  22. "-DPCAPPP_BUILD_EXAMPLES=OFF",
  23. "-DPCAPPP_BUILD_TESTS=OFF",
  24. }
  25. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  26. import("package.tools.cmake").install(package, configs)
  27. end)
  28. on_test(function (package)
  29. assert(package:check_cxxsnippets({test = [[
  30. #include "pcapplusplus/IPv4Layer.h"
  31. #include "pcapplusplus/Packet.h"
  32. #include "pcapplusplus/PcapFileDevice.h"
  33. void test() {
  34. pcpp::PcapFileReaderDevice reader("1_packet.pcap");
  35. }
  36. ]]}, {configs = {languages = "c++17"}}))
  37. end)