Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/topic/timw/fix-pcap-override'
Browse files Browse the repository at this point in the history
* origin/topic/timw/fix-pcap-override:
  Make sure that vcpkg isn't preferred if pcap_root_dir is passed in
  • Loading branch information
timwoj committed Apr 11, 2024
2 parents 50e3d75 + 3d13d3a commit 1d79336
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion FindPCAP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,18 @@

find_path(PCAP_ROOT_DIR NAMES include/pcap.h Include/pcap.h)

find_path(PCAP_INCLUDE_DIR NAMES pcap.h HINTS ${PCAP_ROOT_DIR}/include)
# If this is MSVC and a different root path was provided to cmake, add the vcpkg paths to
# the list of ignored paths for the rest of this file. This prevents cmake from preferring
# vcpkg over the path requested.
set(_old_cmake_ignore_path ${CMAKE_IGNORE_PATH})
string(FIND "${PCAP_ROOT_DIR}" "vcpkg" _is_vcpkg_root)
if (MSVC AND _is_vcpkg_root LESS 0)
set(CMAKE_IGNORE_PATH ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include)
list(APPEND CMAKE_IGNORE_PATH ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib)
list(APPEND CMAKE_IGNORE_PATH ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib)
endif ()

find_path(PCAP_INCLUDE_DIR NAMES pcap.h HINTS ${PCAP_ROOT_DIR}/include ${PCAP_ROOT_DIR}/Include)

if (MSVC AND COMPILER_ARCHITECTURE STREQUAL "x86_64")
set(_pcap_lib_hint_path ${PCAP_ROOT_DIR}/lib/x64)
Expand Down Expand Up @@ -72,3 +83,4 @@ check_function_exists(pcap_dump_open_append HAVE_PCAP_DUMP_OPEN_APPEND)
set(CMAKE_REQUIRED_LIBRARIES)

mark_as_advanced(PCAP_ROOT_DIR PCAP_INCLUDE_DIR PCAP_LIBRARY)
set(CMAKE_IGNORE_PATH ${_old_cmake_ignore_path})

0 comments on commit 1d79336

Please sign in to comment.