Commit Graph

24 Commits

Author SHA1 Message Date
Guy Harris
d01ba8bf48 Make tcpdump find wpcap.dll on Windows if it's not in the system library.
See https://npcap.com/guide/npcap-devguide.html#npcap-feature-native-dll-implicitly
for details on what's being done.

Fix #1226.

(cherry picked from commit 89fc9f2161)
2024-10-08 22:08:45 -07:00
Guy Harris
791c536bfc CMake: use pkg-config and Homebrew when looking for libcrypto.
Do the same sort of stuff that configure does, but CMake-style.

(cherry picked from commit fc8465a50d)
2024-07-12 13:03:06 -07:00
Francois-Xavier Le Bail
58e208bdce Fix a typo
[skip ci]

(cherry picked from commit f3af2bebb3)
2022-07-10 16:47:53 +02:00
Guy Harris
15d7577dca On Solaris, for 64-bit builds, use the 64-bit pcap-config.
There are two versions of pcap-config supplied on Solaris (or, at least,
on 64-bit Solaris) - a version that has the right --libs output to find
the 32-bit libraries and a version that has the right --libs output to
find the 64-bit libraries.

Try to figure out whether we're doing a 32-bit or 64-bit build (based on
the pointer size) and, for 64-bit builds, run the 64-bit version of
pcap-config.

(cherry picked from commit c39d40a767)
2021-09-29 15:11:01 +01:00
Guy Harris
8157a31389 CMake: add stuff from CMAKE_PREFIX_PATH to PKG_CONFIG_PATH.
Pull in some code from CMake 3.12.4's FindPkgConfig.cmake to arrange
that, when running pkg-config, directories from CMAKE_PREFIX_PATH are in
the PKG_CONFIG_PATH environment variable.

We do this because we want to make sure that, if CMAKE_PREFIX_PATH is
set, and it points to a directory that contains a libpcap that has a .pc
file installed, we get that .pc file, but we don't yet want to require a
minimum of CMake 3.1 or later (CMake 3.1 and later do that
automatically) because there might be some long-term support OS version
that comes with an older version of CMake.

(cherry picked from commit 8ceef287ad)
2021-03-31 13:24:13 +02:00
Guy Harris
d0963e4032 Add a comment about how to tell this where to find pcap.
Most of the time this probably won't be an issue on UN*Xes, but it'll
probably be an issue on Windows.
2020-02-04 20:57:18 -08:00
Francois-Xavier Le Bail
ab450fb62d Remove trailing spaces 2019-08-16 13:52:46 +02:00
Guy Harris
f57a25811d Add a message for pcap-config, and suppress messages with QUIET.
We have messages for pkg-config and for the old-fashioned search; print
a message if pkg-config failed but we found pcap-config.

Fix the suppression of messages with a QUIET argument.
2019-04-29 18:41:20 -07:00
Guy Harris
d33ba72b2d To search for a library under multiple names, say "NAMES name1 name2 ...". 2019-04-29 12:06:34 -07:00
Guy Harris
87207f2b1a Redo the checks for libpcap.
On Windows, don't bother with pkg-config or pcap-config.  We make no
effort, in libpcap, to make them work on Windows, we don't install the
.pc files or pcap-config on Windows with the CMake build, and neither
WinPcap nor Npcap install them.

On UN*X:

For pkg-config and pcap-config, set variables named CONFIG_PCAP_xxx.
pkg-config's xxx_LIBRARIES and xxx_STATIC_LIBRARIES variables have only
library names, not library full paths, so we need to use find_library()
to convert them to full paths.  For pcap-config, generate
library-name-only CONFIG_PCAP_LIBRARIES and CONFIG_PCAP_STATIC_LIBRARIES
variables, as well as CONFIG_PCAP_FOUND.

If CONFIG_PCAP_FOUND is true, meaning that either pkg-config or
pcap-config succeeded, copy CONFIG_PCAP_INCLUDE_DIRS to
PCAP_INCLUDE_DIRS, iterate over CONFIG_PCAP_LIBRARIES and
CONFIG_PCAP_STATIC_LIBRARIES to generate full paths for all of the
libraries and put them in PCAP_LIBRARIES and PCAP_STATIC_LIBRARIES, and
set PCAP_FOUND.

If CONFIG_PCAP_FOUND is false, search for headers and libraries
ourselves.
2019-04-29 11:55:27 -07:00
Guy Harris
45a4d4292c Use pkg-config if we can. Clean up some CMake stuff.
If we have pkg-config, *and* it has .pc files for libpcap, use it to get
the C compiler flags and linker flags for libpcap.

find_library() sets a cache variable; when we're looping over libraries,
trying to find their full paths, we really want the variable to act as a
local variable, as we're looking up different libraries, so unset it
after we're finished processing a particular library.

When we're searching for static libraries, save the current value of
CMAKE_FIND_LIBRARY_SUFFIXES, set it to ".a", and then restore it when
we're done.  Don't use cmake_push_check_state() for that, as
CMAKE_FIND_LIBRARY_SUFFIXES is *not* one of the variables that it's
guaranteed to save and restore.
2019-04-26 13:15:39 -07:00
Guy Harris
7f260fa85e Fix tpo in previous commit. 2019-04-26 01:18:34 -07:00
Guy Harris
26b4559a43 Clean up the find module for libpcap.
It should set PCAP_INCLUDE_DIRS, PCAP_LIBRARIES and
PCAP_STATIC_LIBRARIES, plural.  Do that, and don't bother setting
PCAP_INCLUDE_DIR or PCAP_LIBRARY.
2019-04-25 21:36:28 -07:00
Guy Harris
e5c7dcdc04 Try to find the 64-bit libraries in a 64-bit build. 2018-09-13 16:26:39 -07:00
Guy Harris
047b5aeb97 Handle the output of pcap-config --cflags being empty.
Quote it in the string(REGEX REPLACE) call.
2018-07-12 10:30:10 -07:00
Guy Harris
c640a96c6a Fixtypo. 2018-01-28 21:06:22 -08:00
Guy Harris
c766e8cfad On Windows, if we don't find libpcap, look for libwpcap.
Also, while there may not be a convention for "look for package XXX
here", there is a convention for "look for stuff here" - put "here" in
CMAKE_PREFIX_PATH.  So don't use PCAP_DLL_DIR, just let find_path() and
find_library() search where you tell it (on Windows *or* UN*X).
2018-01-28 19:42:47 -08:00
Guy Harris
341b863394 Add support for PCAP_DLL_DIR as a hint on Windows. 2018-01-28 19:24:22 -08:00
Guy Harris
95eb8be7f8 Set PCAP_INCLUDE_DIRS as well as PCAP_INCLUDE_DIR. 2018-01-26 23:48:59 -08:00
Guy Harris
253ef5db82 Don't do "here's the directories in which to look for libraries".
CMake *hates* that.  -L considered harmful, I guess (and I don't know
how that's done with tools other than UN*X linkers - do all of them
support an equivalent to -L?).

This should fix the checks for pcap functions to look in the library we
found.
2018-01-26 20:02:32 -08:00
Guy Harris
213f7585eb Use pcap-config if we have it.
Also, provide support for linking statically with pcap.
2018-01-26 00:49:21 -08:00
Guy Harris
b5a60ccbd1 Set XXX_INCLUDE_DIRS and XXX_LIBRARIES in find modules.
That appears to be the convention.
2018-01-23 12:45:26 -08:00
Guy Harris
54587515ef Add libcrypto checks.
Put the optional libraries after libpcap, which is *not* optional.
2018-01-22 17:20:02 -08:00
Guy Harris
1807273b16 Initial CMake support.
Work in progress; there's more to be done.
2018-01-21 13:22:15 -08:00