diff --git a/recipes/libpcap/all/conanfile.py b/recipes/libpcap/all/conanfile.py index 10fbd7a3b7b60..1cbe6a152dae8 100644 --- a/recipes/libpcap/all/conanfile.py +++ b/recipes/libpcap/all/conanfile.py @@ -5,7 +5,7 @@ from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout from conan.tools.env import VirtualBuildEnv, VirtualRunEnv from conan.tools.files import chdir, copy, get, rm, rmdir -from conan.tools.gnu import Autotools, AutotoolsDeps, AutotoolsToolchain +from conan.tools.gnu import Autotools, AutotoolsDeps, AutotoolsToolchain, PkgConfigDeps from conan.tools.layout import basic_layout from conan.tools.microsoft import is_msvc, is_msvc_static_runtime from conan.tools.scm import Version @@ -28,21 +28,22 @@ class LibPcapConan(ConanFile): options = { "shared": [True, False], "fPIC": [True, False], + "enable_dbus": [True, False], + "enable_libnl": [True, False], "enable_libusb": [True, False], + "enable_rdma": [True, False], "with_snf": [True, False], } default_options = { "shared": False, "fPIC": True, + "enable_dbus": False, + "enable_libnl": False, "enable_libusb": False, + "enable_rdma": False, "with_snf": False, } - # TODO: Add dbus-glib when available - # TODO: Add libnl-genl when available - # TODO: Add libbluetooth when available - # TODO: Add libibverbs when available - @property def _settings_build(self): return getattr(self, "settings_build", self.settings) @@ -52,6 +53,8 @@ def config_options(self): del self.options.fPIC if self.settings.os != "Linux": del self.options.enable_libusb + del self.options.enable_libnl + del self.options.enable_rdma def configure(self): if self.options.shared: @@ -68,6 +71,13 @@ def layout(self): def requirements(self): if self.options.get_safe("enable_libusb"): self.requires("libusb/1.0.26") + if self.options.get_safe("enable_libnl"): + self.requires("libnl/3.8.0") + if self.options.get_safe("enable_rdma"): + self.requires("rdma-core/52.0") + if self.options.get_safe("enable_dbus"): + self.requires("dbus/1.15.8") + # TODO: Add libbluetooth when available def validate(self): if Version(self.version) < "1.10.0" and self.settings.os == "Macos" and self.options.shared: @@ -80,7 +90,7 @@ def validate(self): def build_requirements(self): if self._settings_build.os == "Windows": - self.tool_requires("winflexbison/2.5.24") + self.tool_requires("winflexbison/2.5.25") else: self.tool_requires("bison/3.8.2") self.tool_requires("flex/2.6.4") @@ -109,16 +119,16 @@ def generate(self): tc = AutotoolsToolchain(self) yes_no = lambda v: "yes" if v else "no" tc.configure_args.extend([ - f"--enable-usb={yes_no(self.options.get_safe('enable_libusb'))}", - "--disable-universal", - "--without-libnl", + "--disable-universal", # don't build universal binaries on macOS + "--enable-usb" if self.options.get_safe("enable_libusb") else "--disable-usb", + "--enable-dbus" if self.options.get_safe("enable_dbus") else "--disable-dbus", + "--enable-rdma" if self.options.get_safe("enable_rdma") else "--disable-rdma", + "--with-libnl" if self.options.get_safe("enable_libnl") else "--without-libnl", "--disable-bluetooth", - "--disable-packet-ring", - "--disable-dbus", - "--disable-rdma", f"--with-snf={yes_no(self.options.get_safe('with_snf'))}", ]) - + if Version(self.version) < "1.10": + tc.configure_args.append("--disable-packet-ring") if cross_building(self): target_os = "linux" if self.settings.os == "Linux" else "null" tc.configure_args.append(f"--with-pcap={target_os}") @@ -127,6 +137,8 @@ def generate(self): tc.generate() AutotoolsDeps(self).generate() + deps = PkgConfigDeps(self) + deps.generate() def build(self): if self.settings.os == "Windows": @@ -175,5 +187,13 @@ def package_info(self): self.cpp_info.libs = [f"pcap{suffix}"] if self.settings.os == "Windows": self.cpp_info.system_libs = ["ws2_32"] + if self.options.get_safe("enable_libusb"): + self.cpp_info.requires.append("libusb::libusb") + if self.options.get_safe("enable_libnl"): + self.cpp_info.requires.append("libnl::nl-genl") + if self.options.get_safe("enable_rdma"): + self.cpp_info.requires.append("rdma-core::libibverbs") + if self.options.get_safe("enable_dbus"): + self.cpp_info.requires.append("dbus::dbus") if self.options.get_safe("with_snf"): self.cpp_info.system_libs.append("snf")