]> The Tcpdump Group git mirrors - tcpdump/blobdiff - cmake/Modules/FindPCAP.cmake
Add printing support for vsockmon devices.
[tcpdump] / cmake / Modules / FindPCAP.cmake
index 5ce53d3cea73a70a6dd837e8fe44ecb9b1ffa8dc..a41356778c090fab59ffcaa3723ea5d7a0562c52 100644 (file)
@@ -24,7 +24,7 @@ if(PCAP_CONFIG)
   # XXX - this assumes that there's only one -I flag in the output
   # of pcap-config --cflags.  That *should* be the case.
   #
-  string(REGEX REPLACE "-I" "" PCAP_INCLUDE_DIRS ${PCAP_CONFIG_OUTPUT})
+  string(REGEX REPLACE "-I" "" PCAP_INCLUDE_DIRS "${PCAP_CONFIG_OUTPUT}")
   set(PCAP_INCLUDE_DIR ${PCAP_INCLUDE_DIRS})
 
   # Now, get the libraries.
@@ -98,32 +98,43 @@ if(PCAP_CONFIG)
   find_library(PCAP_STATIC_LIBRARY pcap HINTS ${_pcap_static_library_dirs})
   cmake_pop_check_state()
 else(PCAP_CONFIG)
-  if(WIN32)
-    #
-    # On Windows, we support PCAP_DLL_DIR being set to the path of
-    # a directory containing an SDK for {whatever}Pcap.
-    # XXX - is there a CMake convention for "look for package XXX
-    # here"?
-    #
-    # Try to find the header
-    find_path(PCAP_INCLUDE_DIR pcap.h HINTS ${PCAP_DLL_DIR})
-
-    # Try to find the library
-    find_library(PCAP_LIBRARY pcap HINTS ${PCAP_DLL_DIR})
-  else(WIN32)
-    # Try to find the header
-    find_path(PCAP_INCLUDE_DIR pcap.h)
+  # Try to find the header
+  find_path(PCAP_INCLUDE_DIR pcap.h)
 
-    # Try to find the library
-    find_library(PCAP_LIBRARY pcap)
+  # Try to find the library
+  if(WIN32)
+    # The 64-bit Packet.lib is located under /x64
+    if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+      #
+      # For the WinPcap and Npcap SDKs, the Lib subdirectory of the top-level
+      # directory contains 32-bit libraries; the 64-bit libraries are in the
+      # Lib/x64 directory.
+      #
+      # The only way to *FORCE* CMake to look in the Lib/x64 directory
+      # without searching in the Lib directory first appears to be to set
+      # CMAKE_LIBRARY_ARCHITECTURE to "x64".
+      #
+      set(CMAKE_LIBRARY_ARCHITECTURE "x64")
+    endif()
+  endif()
 
+  find_library(PCAP_LIBRARY pcap)
+  if(WIN32)
+    if(NOT PCAP_LIBRARY)
+      #
+      # OK, look for it under the name wpcap.
+      #
+      find_library(PCAP_LIBRARY wpcap)
+    endif(NOT PCAP_LIBRARY)
+  endif(WIN32)
+  if(NOT WIN32)
     # Try to find the static library (XXX - what about AIX?)
     include(CMakePushCheckState)
     cmake_push_check_state()
     set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
     find_library(PCAP_STATIC_LIBRARY pcap)
     cmake_pop_check_state()
-  endif(WIN32)
+  endif(NOT WIN32)
 
   set(PCAP_INCLUDE_DIRS ${PCAP_INCLUDE_DIR})
   set(PCAP_LIBRARIES ${PCAP_LIBRARY})