xmake.lua 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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_patches("v24.09", "patches/v24.09/vla.patch", "8c380468c78118b6d85f6b3856cd49c4d890fd326dde3400b8c47c01c885cef4")
  10. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  11. add_links("Pcap++", "Packet++", "Common++")
  12. if is_plat("windows", "mingw") then
  13. add_syslinks("ws2_32", "iphlpapi")
  14. elseif is_plat("macosx") then
  15. add_frameworks("CoreFoundation", "SystemConfiguration")
  16. elseif is_plat("linux", "bsd") then
  17. add_syslinks("pthread")
  18. end
  19. add_deps("cmake")
  20. if is_plat("windows", "mingw") then
  21. add_deps("npcap_sdk")
  22. elseif is_plat("linux", "macosx", "android", "bsd") then
  23. add_deps("libpcap")
  24. end
  25. on_install("windows", "mingw", "linux", "macosx", "android", "bsd", function (package)
  26. local configs = {
  27. "-DPCAPPP_BUILD_EXAMPLES=OFF",
  28. "-DPCAPPP_BUILD_TESTS=OFF",
  29. }
  30. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  31. import("package.tools.cmake").install(package, configs)
  32. end)
  33. on_test(function (package)
  34. assert(package:check_cxxsnippets({test = [[
  35. #include <vector>
  36. #include "pcapplusplus/IPv4Layer.h"
  37. #include "pcapplusplus/Packet.h"
  38. #include "pcapplusplus/PcapFileDevice.h"
  39. #include "pcapplusplus/PcapLiveDeviceList.h"
  40. void testPcapFileReaderDevice() {
  41. pcpp::PcapFileReaderDevice reader("1_packet.pcap");
  42. }
  43. void testPcapLiveDeviceList() {
  44. std::vector<pcpp::PcapLiveDevice *> devList =
  45. pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDevicesList();
  46. }
  47. ]]}, {configs = {languages = "c++17"}}))
  48. end)