Skip to content

Provide compile time feature availability querying capability. #2129

@Dimi1010

Description

@Dimi1010

Description

Currently once the library is built (and installed), it does not provide an easy way for users to query which features are available at compile time. The only indication that the library has not been build without certain features in some cases is the include headers missing, which leads to compile time errors and issues if the consuming library must seamlessly support several optional feature sets.

The main features to be considered for this proposal are:

  • zstd file support
  • libpcap / winpcap / npcap
  • dpdk + kni
  • pfring
  • windivert
  • xdp

Proposal

A possible solution leverage CMake's target based compile definitions machinery to provide PUBLIC defines in the form of PCPP_HAS_XXX_SUPPORT=1. The public definition will in turn propagate the define to targets that consume the library target allowing them to be used at compile time.

Example change to cmake configuration:

add_library(Pcap++ ...)

if(PCAPPP_USE_DPDK)
  target_compile_definitions(Pcap++ PUBLIC PCPP_HAS_DPDK_SUPPORT=1)
endif()

Example usage:

#ifdef PCPP_HAS_DPDK_SUPPORT
#include "DpdkDeviceList.h"
#endif

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions