1
0
mirror of https://github.com/open-simh/simh.git synced 2026-05-23 13:56:09 +00:00
Files
open-simh.simh/cmake/FindPCAP.cmake
Dan Cross 0e985346b1 FreeBSD: link against libpcap
On FreeBSD, one must actually link against libpcap
(or give the path to a shared object at link
time).  That is, it is not a header-only library
on that platform.

Account for this by adding a new boolean variable
in `platform-quirks.cmake`: `NEED_PCAP_LIBRARY`,
which defaults to false.  Condition pcap library
discovery and link argument modifications on that
variable in `FindPCAP.cmake` and `dep-link.cmake`.
2026-05-03 14:19:02 -04:00

89 lines
2.2 KiB
CMake

# Locate the PCAP library
#
# This module defines:
#
# ::
#
# PCAP_LIBRARIES, the name of the library to link against
# PCAP_INCLUDE_DIRS, where to find the headers
# PCAP_FOUND, if false, do not try to link against
# PCAP_VERSION_STRING - human-readable string containing the version of SDL_ttf
#
# Tweaks:
# 1. PCAP_PATH: A list of directories in which to search
# 2. PCAP_DIR: An environment variable to the directory where you've unpacked or installed PCAP.
#
# "scooter me fecit"
find_path(PCAP_INCLUDE_DIR
NAMES
pcap.h
HINTS
ENV PCAP_DIR
PATHS
pcap
PCAP
${PCAP_PATH}
)
# if (CMAKE_SIZEOF_VOID_P EQUAL 8)
# set(LIB_PATH_SUFFIXES lib64 x64 amd64 x86_64-linux-gnu aarch64-linux-gnu lib)
# else ()
# set(LIB_PATH_SUFFIXES x86)
# endif ()
if (NEED_PCAP_LIBRARY)
find_library(PCAP_LIBRARY
NAMES
pcap pcap_static libpcap libpcap_static
HINTS
ENV PCAP_DIR
PATH_SUFFIXES
${LIB_PATH_SUFFIXES}
PATHS
${PCAP_PATH}
)
message(STATUS "LIB_PATH_SUFFIXES ${LIB_PATH_SUFFIXES}")
message(STATUS "PCAP_LIBRARY is ${PCAP_LIBRARY}")
endif()
# if (WIN32 AND PCAP_LIBRARY)
# ## Only worry about the packet library on Windows.
# find_library(PACKET_LIBRARY
# NAMES
# packet Packet
# HINTS
# ENV PCAP_DIR
# PATH_SUFFIXES
# ${LIB_PATH_SUFFIXES}
# PATHS
# ${PCAP_PATH}
# )
# else (WIN32 AND PCAP_LIBRARY)
# set(PACKET_LIBRARY)
# endif (WIN32 AND PCAP_LIBRARY)
# ## message(STATUS "PACKET_LIBRARY is ${PACKET_LIBRARY}")
if (NEED_PCAP_LIBRARY)
set(PCAP_LIBRARIES ${PCAP_LIBRARY} ${PACKET_LIBRARY})
endif()
set(PCAP_INCLUDE_DIRS ${PCAP_INCLUDE_DIR})
unset(PCAP_LIBRARY)
unset(PCAP_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
if (NEED_PCAP_LIBRARY)
find_package_handle_standard_args(
PCAP
REQUIRED_VARS
PCAP_LIBRARIES
PCAP_INCLUDE_DIRS
)
else()
find_package_handle_standard_args(
PCAP
REQUIRED_VARS
PCAP_INCLUDE_DIRS
)
endif()