wireshark/doc/plugins.example
John Thacker c7d99f6951 CMake: Require CMake 3.16 or later
Qt says: "Qt projects are required to set version 3.16 or newer in the
cmake_minimum_required command to ensure a working set of policy behaviors."
https://doc.qt.io/qt-6/cmake-supported-cmake-versions.html

We haven't noticed any problems, but 3.16 is 5 years old, and all the
Linux distributions that currently build the latest sources come with
CMake 3.16 or later. Ubuntu 20.04 (focal), which goes end of standard
support in April 2025, has 3.16 (that focal is stuck on Qt 5.12 without
using a PPA is a bigger issue that may warrant dropping support before
the next major Wireshark release.)

Also update the example plugin minimum CMake version to match.
2024-10-08 15:29:14 +00:00
..

This is an example of how to build a Wireshark plugin out-of-tree. This
is an alternative, more recent way to build Wireshark binary plugins,
than the one in 'README.plugins', that describes in detail how to
include a new plugin into the project source tree (here called in-tree
build). Building a plugin out-of-tree doesn't require rebuilding the whole
Wireshark source tree every time.

You always need to rebuild plugins for each major.minor Wireshark version.
Binary compatibility is never guaranteed between those releases and Wireshark
will explicitly check for which version the plugin was built and refuse
to load it otherwise.

Note that the out-of-tree method builds the plugin using CMake's Config-file
mechanism[1] for configuration. In other words the plugin build system uses
the Wireshark headers that were installed on the system using "make install"
or equivalent (as configured from WiresharkConfig.cmake). This is not the same
as an in-tree build.

You should of course adapt this trivial example to your own needs.

To build/install the plugin:

$ mkdir build && cd build
$ cmake ..
$ make
$ sudo make install

If your WiresharkConfig.cmake file is not in one of the standard cmake search
paths you will have to tell cmake where to find it. You can do so using
CMAKE_PREFIX_PATH, for example:

$ cmake -DCMAKE_PREFIX_PATH="/opt/wireshark" ..

[1]https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#config-file-packages