xmake.lua 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  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_urls("https://github.com/seladb/PcapPlusPlus/archive/refs/tags/$(version).zip",
  5. "https://github.com/seladb/PcapPlusPlus.git")
  6. add_versions("v23.09", "f2b92d817df6138363be0d144a61716f8ecc43216f0008135da2e0e15727d35a")
  7. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  8. add_deps("cmake")
  9. if is_plat("windows") then
  10. add_syslinks("ws2_32")
  11. add_deps("npcap_sdk")
  12. end
  13. on_install("windows", function (package)
  14. local configs = {}
  15. table.insert(configs, "-DPCAPPP_BUILD_EXAMPLES=OFF")
  16. table.insert(configs, "-DPCAPPP_BUILD_TESTS=OFF")
  17. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  18. import("package.tools.cmake").install(package, configs)
  19. end)
  20. on_test(function (package)
  21. assert(package:check_cxxsnippets({test = [[
  22. #include "pcapplusplus/IPv4Layer.h"
  23. #include "pcapplusplus/Packet.h"
  24. #include "pcapplusplus/PcapFileDevice.h"
  25. void test() {
  26. pcpp::PcapFileReaderDevice reader("1_packet.pcap");
  27. }
  28. ]]}, {configs = {languages = "c++17"}}))
  29. end)