]> The Tcpdump Group git mirrors - libpcap/blob - cmake/FindPacket.cmake
Clean up the ether_hostton() stuff.
[libpcap] / cmake / FindPacket.cmake
1 #
2 # Copyright (C) 2017 Ali Abdulkadir <autostart.ini@gmail.com>.
3 #
4 # Permission is hereby granted, free of charge, to any person
5 # obtaining a copy of this software and associated documentation files
6 # (the "Software"), to deal in the Software without restriction,
7 # including without limitation the rights to use, copy, modify, merge,
8 # publish, distribute, sub-license, and/or sell copies of the Software,
9 # and to permit persons to whom the Software is furnished to do so,
10 # subject to the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be
13 # included in all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19 # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 # SOFTWARE.
23 #
24 # FindPacket
25 # ==========
26 #
27 # Find the Packet library and include files.
28 #
29 # This module defines the following variables:
30 #
31 # PACKET_INCLUDE_DIR - absolute path to the directory containing Packet32.h.
32 # PACKET_LIBRARY - absolute path to the Packet library to link with.
33 # PACKET_FOUND - true if the Packet library *and* its headers are found.
34 #
35 # Hints and Backward Compatibility
36 # ================================
37 #
38 # To tell this module where to look, a user may set the environment variable
39 # PACKET_DLL_DIR to point cmake to the *root* of a directory with include and lib
40 # subdirectories for packet.dll (e.g WpdPack/npcap-sdk).
41 # Alternatively, PACKET_DLL_DIR may also be set from cmake command line or GUI
42 # (e.g cmake -DPACKET_DLL_DIR=/path/to/packet [...])
43 #
44
45 if(NOT PACKET_DLL_DIR)
46 set(PACKET_DLL_DIR $ENV{PACKET_DLL_DIR})
47 endif()
48
49 # The 64-bit Packet.lib is located under /x64
50 # MinGW users may manually define TARGET_IS_MINGW64 to point to /x64
51 set(64BIT_SUBDIR "")
52 if(CMAKE_CL_64 OR TARGET_IS_MINGW64)
53 set(64BIT_SUBDIR "/x64")
54 endif()
55
56 # Find the header
57 find_path(PACKET_INCLUDE_DIR Packet32.h
58 HINTS "${PACKET_DLL_DIR}"
59 PATH_SUFFIXES include Include
60 )
61
62 if(PACKET_INCLUDE_DIR)
63 message(STATUS "Found Packet32.h: ${PACKET_INCLUDE_DIR}")
64 # else()
65 # message(FATAL_ERROR "Could not find Packet32.h. See README.Win32 for more information.")
66 endif()
67
68 # Find the library
69 find_library(PACKET_LIBRARY
70 NAMES Packet packet
71 HINTS "${PACKET_DLL_DIR}"
72 PATH_SUFFIXES Lib${64BIT_SUBDIR} lib${64BIT_SUBDIR}
73 )
74
75 if(PACKET_LIBRARY)
76 message(STATUS "Found Packet library: ${PACKET_LIBRARY}")
77 set(HAVE_PACKET ${PACKET_LIBRARY})
78 # else()
79 # message(FATAL_ERROR "Could not find Packet library. See README.Win32 for more information.")
80 endif()
81
82 if(PACKET_INCLUDE_DIR AND PACKET_LIBRARY)
83 set(PACKET_FOUND TRUE)
84 endif()
85
86 mark_as_advanced(PACKET_INCLUDE_DIR PACKET_LIBRARY)