1b00ab754SHans Petter Selasky# 2b00ab754SHans Petter Selasky# Copyright (C) 2017 Ali Abdulkadir <autostart.ini@gmail.com>. 3b00ab754SHans Petter Selasky# 4b00ab754SHans Petter Selasky# Permission is hereby granted, free of charge, to any person 5b00ab754SHans Petter Selasky# obtaining a copy of this software and associated documentation files 6b00ab754SHans Petter Selasky# (the "Software"), to deal in the Software without restriction, 7b00ab754SHans Petter Selasky# including without limitation the rights to use, copy, modify, merge, 8b00ab754SHans Petter Selasky# publish, distribute, sub-license, and/or sell copies of the Software, 9b00ab754SHans Petter Selasky# and to permit persons to whom the Software is furnished to do so, 10b00ab754SHans Petter Selasky# subject to the following conditions: 11b00ab754SHans Petter Selasky# 12b00ab754SHans Petter Selasky# The above copyright notice and this permission notice shall be 13b00ab754SHans Petter Selasky# included in all copies or substantial portions of the Software. 14b00ab754SHans Petter Selasky# 15b00ab754SHans Petter Selasky# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16b00ab754SHans Petter Selasky# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17b00ab754SHans Petter Selasky# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18b00ab754SHans Petter Selasky# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19b00ab754SHans Petter Selasky# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20b00ab754SHans Petter Selasky# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21b00ab754SHans Petter Selasky# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22b00ab754SHans Petter Selasky# SOFTWARE. 23b00ab754SHans Petter Selasky# 24b00ab754SHans Petter Selasky# FindPacket 25b00ab754SHans Petter Selasky# ========== 26b00ab754SHans Petter Selasky# 27b00ab754SHans Petter Selasky# Find the Packet library and include files. 28b00ab754SHans Petter Selasky# 29b00ab754SHans Petter Selasky# This module defines the following variables: 30b00ab754SHans Petter Selasky# 31b00ab754SHans Petter Selasky# PACKET_INCLUDE_DIR - absolute path to the directory containing Packet32.h. 32b00ab754SHans Petter Selasky# 33b00ab754SHans Petter Selasky# PACKET_LIBRARY - relative or absolute path to the Packet library to 34b00ab754SHans Petter Selasky# link with. An absolute path is will be used if the 35b00ab754SHans Petter Selasky# Packet library is not located in the compiler's 36b00ab754SHans Petter Selasky# default search path. See e.g. PACKET_DLL_DIR 37b00ab754SHans Petter Selasky# variable below. 38b00ab754SHans Petter Selasky 39b00ab754SHans Petter Selasky# PACKET_FOUND - TRUE if the Packet library *and* header are found. 40b00ab754SHans Petter Selasky# 41b00ab754SHans Petter Selasky# Hints and Backward Compatibility 42b00ab754SHans Petter Selasky# ================================ 43b00ab754SHans Petter Selasky# 44b00ab754SHans Petter Selasky# To tell this module where to look, a user may set the environment variable 45b00ab754SHans Petter Selasky# PACKET_DLL_DIR to point cmake to the *root* of a directory with include and 46b00ab754SHans Petter Selasky# lib subdirectories for packet.dll (e.g WpdPack/npcap-sdk). 47b00ab754SHans Petter Selasky# Alternatively, PACKET_DLL_DIR may also be set from cmake command line or GUI 48b00ab754SHans Petter Selasky# (e.g cmake -DPACKET_DLL_DIR=/path/to/packet [...]) 49b00ab754SHans Petter Selasky# 50b00ab754SHans Petter Selasky 51b00ab754SHans Petter Selasky# The 64-bit Packet.lib is located under /x64 52b00ab754SHans Petter Selaskyif(CMAKE_SIZEOF_VOID_P EQUAL 8) 53*57e22627SCy Schubert # 54*57e22627SCy Schubert # For the WinPcap and Npcap SDKs, the Lib subdirectory of the top-level 55*57e22627SCy Schubert # directory contains 32-bit libraries; the 64-bit libraries are in the 56*57e22627SCy Schubert # Lib/x64 directory. 57*57e22627SCy Schubert # 58*57e22627SCy Schubert # The only way to *FORCE* CMake to look in the Lib/x64 directory 59*57e22627SCy Schubert # without searching in the Lib directory first appears to be to set 60*57e22627SCy Schubert # CMAKE_LIBRARY_ARCHITECTURE to "x64". 61*57e22627SCy Schubert # 62*57e22627SCy Schubert set(CMAKE_LIBRARY_ARCHITECTURE "x64") 63b00ab754SHans Petter Selaskyendif() 64b00ab754SHans Petter Selasky 65b00ab754SHans Petter Selasky# Find the header 66b00ab754SHans Petter Selaskyfind_path(PACKET_INCLUDE_DIR Packet32.h 67b00ab754SHans Petter Selasky HINTS "${PACKET_DLL_DIR}" ENV PACKET_DLL_DIR 68b00ab754SHans Petter Selasky PATH_SUFFIXES include Include 69b00ab754SHans Petter Selasky) 70b00ab754SHans Petter Selasky 71b00ab754SHans Petter Selasky# Find the library 72b00ab754SHans Petter Selaskyfind_library(PACKET_LIBRARY 73b00ab754SHans Petter Selasky NAMES Packet packet 74b00ab754SHans Petter Selasky HINTS "${PACKET_DLL_DIR}" ENV PACKET_DLL_DIR 75b00ab754SHans Petter Selasky) 76b00ab754SHans Petter Selasky 77b00ab754SHans Petter Selasky# Set PACKET_FOUND to TRUE if PACKET_INCLUDE_DIR and PACKET_LIBRARY are TRUE. 78b00ab754SHans Petter Selaskyinclude(FindPackageHandleStandardArgs) 79b00ab754SHans Petter Selaskyfind_package_handle_standard_args(PACKET 80b00ab754SHans Petter Selasky DEFAULT_MSG 81b00ab754SHans Petter Selasky PACKET_INCLUDE_DIR 82b00ab754SHans Petter Selasky PACKET_LIBRARY 83b00ab754SHans Petter Selasky) 84b00ab754SHans Petter Selasky 85b00ab754SHans Petter Selaskymark_as_advanced(PACKET_INCLUDE_DIR PACKET_LIBRARY) 86b00ab754SHans Petter Selasky 87b00ab754SHans Petter Selaskyset(PACKET_INCLUDE_DIRS ${PACKET_INCLUDE_DIR}) 88b00ab754SHans Petter Selaskyset(PACKET_LIBRARIES ${PACKET_LIBRARY}) 89