xref: /freebsd-src/contrib/libpcap/cmake/Modules/FindAirPcap.cmake (revision 6f9cba8f8b5efd16249633e52483ea351876b67b)
1*6f9cba8fSJoseph Mingrone#
2*6f9cba8fSJoseph Mingrone# FindAirPcap
3*6f9cba8fSJoseph Mingrone# ==========
4*6f9cba8fSJoseph Mingrone#
5*6f9cba8fSJoseph Mingrone# Find the AirPcap library and include files.
6*6f9cba8fSJoseph Mingrone#
7*6f9cba8fSJoseph Mingrone# This module defines the following variables:
8*6f9cba8fSJoseph Mingrone#
9*6f9cba8fSJoseph Mingrone# AirPcap_INCLUDE_DIR     - absolute path to the directory containing airpcap.h.
10*6f9cba8fSJoseph Mingrone#
11*6f9cba8fSJoseph Mingrone# AirPcap_LIBRARY         - relative or absolute path to the AirPcap library to
12*6f9cba8fSJoseph Mingrone#                          link with. An absolute path is will be used if the
13*6f9cba8fSJoseph Mingrone#                          AirPcap library is not located in the compiler's
14*6f9cba8fSJoseph Mingrone#                          default search path.
15*6f9cba8fSJoseph Mingrone
16*6f9cba8fSJoseph Mingrone# AirPcap_FOUND           - TRUE if the AirPcap library *and* header are found.
17*6f9cba8fSJoseph Mingrone#
18*6f9cba8fSJoseph Mingrone# Hints and Backward Compatibility
19*6f9cba8fSJoseph Mingrone# ================================
20*6f9cba8fSJoseph Mingrone#
21*6f9cba8fSJoseph Mingrone# To tell this module where to look, a user may set the environment variable
22*6f9cba8fSJoseph Mingrone# AirPcap_ROOT to point cmake to the *root* of a directory with include and
23*6f9cba8fSJoseph Mingrone# lib subdirectories for airpcap.dll (e.g Airpcap_Devpack).
24*6f9cba8fSJoseph Mingrone# Alternatively, AirPcap_ROOT may also be set from the CMake command
25*6f9cba8fSJoseph Mingrone# line or GUI (e.g cmake -DAirPcap_ROOT=C:\path\to\airpcap_sdk [...])
26*6f9cba8fSJoseph Mingrone#
27*6f9cba8fSJoseph Mingrone
28*6f9cba8fSJoseph Mingrone# The 64-bit airpcap.lib is located under /x64
29*6f9cba8fSJoseph Mingroneif(CMAKE_SIZEOF_VOID_P EQUAL 8)
30*6f9cba8fSJoseph Mingrone  #
31*6f9cba8fSJoseph Mingrone  # For the WinPcap and Npcap SDKs, the Lib subdirectory of the top-level
32*6f9cba8fSJoseph Mingrone  # directory contains 32-bit libraries; the 64-bit libraries are in the
33*6f9cba8fSJoseph Mingrone  # Lib/x64 directory.
34*6f9cba8fSJoseph Mingrone  #
35*6f9cba8fSJoseph Mingrone  # The only way to *FORCE* CMake to look in the Lib/x64 directory
36*6f9cba8fSJoseph Mingrone  # without searching in the Lib directory first appears to be to set
37*6f9cba8fSJoseph Mingrone  # CMAKE_LIBRARY_ARCHITECTURE to "x64".
38*6f9cba8fSJoseph Mingrone  #
39*6f9cba8fSJoseph Mingrone  # In newer versions of CMake, CMAKE_LIBRARY_ARCHITECTURE is set according to
40*6f9cba8fSJoseph Mingrone  # the language, e.g., CMAKE_<LANG>_LIBRARY_ARCHITECTURE. So, set the new
41*6f9cba8fSJoseph Mingrone  # variable, CMAKE_C_LIBRARY_ARCHITECTURE, so that CMAKE_LIBRARY_ARCHITECTURE
42*6f9cba8fSJoseph Mingrone  # inherits the correct value.
43*6f9cba8fSJoseph Mingrone  #
44*6f9cba8fSJoseph Mingrone  set(CMAKE_C_LIBRARY_ARCHITECTURE "x64")
45*6f9cba8fSJoseph Mingrone  set(CMAKE_LIBRARY_ARCHITECTURE "x64")
46*6f9cba8fSJoseph Mingroneendif()
47*6f9cba8fSJoseph Mingrone
48*6f9cba8fSJoseph Mingrone# Find the header
49*6f9cba8fSJoseph Mingronefind_path(AirPcap_INCLUDE_DIR airpcap.h
50*6f9cba8fSJoseph Mingrone  PATH_SUFFIXES include
51*6f9cba8fSJoseph Mingrone)
52*6f9cba8fSJoseph Mingrone
53*6f9cba8fSJoseph Mingrone# Find the library
54*6f9cba8fSJoseph Mingronefind_library(AirPcap_LIBRARY
55*6f9cba8fSJoseph Mingrone  NAMES airpcap
56*6f9cba8fSJoseph Mingrone)
57*6f9cba8fSJoseph Mingrone
58*6f9cba8fSJoseph Mingrone# Set AirPcap_FOUND to TRUE if AirPcap_INCLUDE_DIR and AirPcap_LIBRARY are TRUE.
59*6f9cba8fSJoseph Mingroneinclude(FindPackageHandleStandardArgs)
60*6f9cba8fSJoseph Mingronefind_package_handle_standard_args(AirPcap
61*6f9cba8fSJoseph Mingrone  DEFAULT_MSG
62*6f9cba8fSJoseph Mingrone  AirPcap_INCLUDE_DIR
63*6f9cba8fSJoseph Mingrone  AirPcap_LIBRARY
64*6f9cba8fSJoseph Mingrone)
65*6f9cba8fSJoseph Mingrone
66*6f9cba8fSJoseph Mingronemark_as_advanced(AirPcap_INCLUDE_DIR AirPcap_LIBRARY)
67*6f9cba8fSJoseph Mingrone
68*6f9cba8fSJoseph Mingroneset(AirPcap_INCLUDE_DIRS ${AirPcap_INCLUDE_DIR})
69*6f9cba8fSJoseph Mingroneset(AirPcap_LIBRARIES ${AirPcap_LIBRARY})
70