1 find_path ( PCap_INCLUDE_DIR NAMES pcap.h pcap/pcap.h DOC "Path to PCap header files." )
2 mark_as_advanced ( PCap_INCLUDE_DIR )
4 find_library ( PCap_LIB NAMES pcap DOC "Location of PCap library." )
5 mark_as_advanced ( PCap_LIB )
7 if ( PCap_INCLUDE_DIR )
8 file ( READ "${PCap_INCLUDE_DIR}/pcap/pcap.h" ver )
10 string ( REGEX MATCH "PCAP_VERSION_MAJOR ([0-9]*)" _ ${ver} )
11 set ( ver_major ${CMAKE_MATCH_1} )
13 string ( REGEX MATCH "PCAP_VERSION_MINOR ([0-9]*)" _ ${ver} )
14 set ( ver_minor ${CMAKE_MATCH_1} )
16 set ( PCap_VERSION "${ver_major}.${ver_minor}" )
21 endif ( PCap_INCLUDE_DIR )
23 include ( FindPackageHandleStandardArgs )
24 find_package_handle_standard_args ( PCap
25 REQUIRED_VARS PCap_LIB PCap_INCLUDE_DIR
26 VERSION_VAR PCap_VERSION )
28 # Create the imported target
30 set ( PCap_INCLUDE_DIRS ${PCap_INCLUDE_DIR} )
31 set ( PCap_LIBRARIES ${PCap_LIB} )
32 if ( NOT TARGET PCap::PCap )
33 add_library ( PCap::PCap UNKNOWN IMPORTED )
34 set_target_properties ( PCap::PCap PROPERTIES
35 IMPORTED_LOCATION "${PCap_LIB}"
36 INTERFACE_INCLUDE_DIRECTORIES "${PCap_INCLUDE_DIR}" )
37 endif ( NOT TARGET PCap::PCap )