summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2019-10-28 18:21:43 -0700
committerGuy Harris <guy@alum.mit.edu>2019-10-31 10:13:52 -0700
commit9ebdfc6e82d385a6c7aa6c15507003ddf56b0547 (patch)
treed1c98f4429957e255f7168ef2d4d8cb4b5679c71
parent86e2d05862a6b8c2dbc41850c9d11cdf3c4fdcb5 (diff)
downloadlibpcap-9ebdfc6e82d385a6c7aa6c15507003ddf56b0547.tar.gz
Use Packet_ROOT to specify the Npcap or WinPcap SDK root directory.
That appears to be the only way to get the CMake that comes with Visual Studio 2019 to reliably find it when we're working entirely through the IDE. I also infer that it might be what the CMake developers intend to be the way to externally specify where to find a package. (cherry picked from commit e230d63c8af6bfc5c85e15d1341be3258d60fb8c)
-rw-r--r--.appveyor.yml2
-rwxr-xr-x[-rw-r--r--]CMakeLists.txt12
-rw-r--r--cmake/Modules/FindPacket.cmake13
3 files changed, 17 insertions, 10 deletions
diff --git a/.appveyor.yml b/.appveyor.yml
index a644151c..ccf96c4f 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -32,5 +32,5 @@ build_script:
- type NUL >.devel
- md build
- cd build
- - cmake -DCMAKE_PREFIX_PATH=c:\projects\libpcap\Win32\%SDK% -G"%GENERATOR%" ..
+ - cmake -DPacket_ROOT=c:\projects\libpcap\Win32\%SDK% -G"%GENERATOR%" ..
- msbuild /m /nologo /p:Configuration=Release pcap.sln
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 55b93f14..08025c8b 100644..100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,6 +9,16 @@ if(POLICY CMP0042)
cmake_policy(SET CMP0042 OLD)
endif()
+#
+# We want find_file() and find_library() to honor {packagename}_ROOT,
+# as that appears to be the only way, with the Visual Studio 2019 IDE
+# and its CMake support, to tell CMake where to look for the Npcap
+# or WinPcap SDK.
+#
+if(POLICY CMP0074)
+ cmake_policy(SET CMP0074 NEW)
+endif()
+
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
project(pcap)
@@ -107,7 +117,7 @@ if(WIN32)
endif(WIN32)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
if(WIN32)
- set(PACKET_DLL_DIR "" CACHE PATH "Path to directory with include and lib subdirectories for packet.dll")
+ set(Packet_ROOT "" CACHE PATH "Path to directory with include and lib subdirectories for packet.dll")
endif(WIN32)
# To pacify those who hate the protochain instruction
diff --git a/cmake/Modules/FindPacket.cmake b/cmake/Modules/FindPacket.cmake
index f114875b..5c398219 100644
--- a/cmake/Modules/FindPacket.cmake
+++ b/cmake/Modules/FindPacket.cmake
@@ -33,8 +33,7 @@
# PACKET_LIBRARY - relative or absolute path to the Packet library to
# link with. An absolute path is will be used if the
# Packet library is not located in the compiler's
-# default search path. See e.g. PACKET_DLL_DIR
-# variable below.
+# default search path.
# PACKET_FOUND - TRUE if the Packet library *and* header are found.
#
@@ -42,10 +41,10 @@
# ================================
#
# To tell this module where to look, a user may set the environment variable
-# PACKET_DLL_DIR to point cmake to the *root* of a directory with include and
-# lib subdirectories for packet.dll (e.g WpdPack/npcap-sdk).
-# Alternatively, PACKET_DLL_DIR may also be set from cmake command line or GUI
-# (e.g cmake -DPACKET_DLL_DIR=/path/to/packet [...])
+# Packet_ROOT to point cmake to the *root* of a directory with include and
+@ lib subdirectories for packet.dll (e.g WpdPack or npcap-sdk).
+# Alternatively, Packet_ROOT may also be set from cmake command line or GUI
+# (e.g cmake -DPacket_ROOT=C:\path\to\packet [...])
#
# The 64-bit Packet.lib is located under /x64
@@ -64,14 +63,12 @@ endif()
# Find the header
find_path(PACKET_INCLUDE_DIR Packet32.h
- HINTS "${PACKET_DLL_DIR}" ENV PACKET_DLL_DIR
PATH_SUFFIXES include Include
)
# Find the library
find_library(PACKET_LIBRARY
NAMES Packet packet
- HINTS "${PACKET_DLL_DIR}" ENV PACKET_DLL_DIR
)
# Set PACKET_FOUND to TRUE if PACKET_INCLUDE_DIR and PACKET_LIBRARY are TRUE.