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