"Fossies" - the Fresh Open Source Software Archive

Member "libpcap-1.10.1/./cmake/Modules/FindPacket.cmake" (7 Jun 2021, 3838 Bytes) of package /linux/misc/libpcap-1.10.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) CMake source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "FindPacket.cmake": 1.10.0_vs_1.10.1.

    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 #
   33 # PACKET_LIBRARY         - relative or absolute path to the Packet library to
   34 #                          link with. An absolute path is will be used if the
   35 #                          Packet library is not located in the compiler's
   36 #                          default search path.
   37 
   38 # PACKET_FOUND           - TRUE if the Packet library *and* header are found.
   39 #
   40 # Hints and Backward Compatibility
   41 # ================================
   42 #
   43 # To tell this module where to look, a user may set the environment variable
   44 # Packet_ROOT to point cmake to the *root* of a directory with include and
   45 # lib subdirectories for packet.dll (e.g WpdPack or npcap-sdk).
   46 # Alternatively, Packet_ROOT may also be set from cmake command line or GUI
   47 # (e.g cmake -DPacket_ROOT=C:\path\to\packet [...])
   48 #
   49 
   50 # The 64-bit Packet.lib is located under /x64
   51 if(CMAKE_SIZEOF_VOID_P EQUAL 8)
   52   #
   53   # For the WinPcap and Npcap SDKs, the Lib subdirectory of the top-level
   54   # directory contains 32-bit libraries; the 64-bit libraries are in the
   55   # Lib/x64 directory.
   56   #
   57   # The only way to *FORCE* CMake to look in the Lib/x64 directory
   58   # without searching in the Lib directory first appears to be to set
   59   # CMAKE_LIBRARY_ARCHITECTURE to "x64".
   60   #
   61   # In newer versions of CMake, CMAKE_LIBRARY_ARCHITECTURE is set according to
   62   # the language, e.g., CMAKE_<LANG>_LIBRARY_ARCHITECTURE. So, set the new
   63   # variable, CMAKE_C_LIBRARY_ARCHITECTURE, so that CMAKE_LIBRARY_ARCHITECTURE
   64   # inherits the correct value.
   65   #
   66   set(archdetect_c_code "
   67   #ifndef _M_ARM64
   68   #error Not ARM64
   69   #endif
   70   int main() { return 0; }
   71   ")
   72 
   73   file(WRITE "${CMAKE_BINARY_DIR}/archdetect.c" "${archdetect_c_code}")
   74   try_compile(
   75       IsArm64 
   76       "${CMAKE_BINARY_DIR}/archdetect"
   77       "${CMAKE_BINARY_DIR}/archdetect.c"
   78       )
   79   if(IsArm64)
   80       set(CMAKE_C_LIBRARY_ARCHITECTURE "ARM64")
   81       set(CMAKE_LIBRARY_ARCHITECTURE "ARM64")
   82   else()
   83       set(CMAKE_C_LIBRARY_ARCHITECTURE "x64")
   84       set(CMAKE_LIBRARY_ARCHITECTURE "x64")
   85   endif()
   86 endif()
   87 
   88 # Find the header
   89 find_path(PACKET_INCLUDE_DIR Packet32.h
   90   PATH_SUFFIXES include Include
   91 )
   92 
   93 # Find the library
   94 find_library(PACKET_LIBRARY
   95   NAMES Packet packet
   96 )
   97 
   98 # Set PACKET_FOUND to TRUE if PACKET_INCLUDE_DIR and PACKET_LIBRARY are TRUE.
   99 include(FindPackageHandleStandardArgs)
  100 find_package_handle_standard_args(PACKET
  101   DEFAULT_MSG
  102   PACKET_INCLUDE_DIR
  103   PACKET_LIBRARY
  104 )
  105 
  106 mark_as_advanced(PACKET_INCLUDE_DIR PACKET_LIBRARY)
  107 
  108 set(PACKET_INCLUDE_DIRS ${PACKET_INCLUDE_DIR})
  109 set(PACKET_LIBRARIES ${PACKET_LIBRARY})