Wireshark’s build environment can be configured using CMake on various UNIX-like platforms, including Linux, macOS, and *BSD, and on Windows. CMake is designed to support out-of-tree builds - so much so that in-tree builds do not work properly in all cases. Along with being cross-platform, CMake supports many build tools and environments including traditional make, Ninja, and MSBuild.
Building with CMake typically includes creating a build directory and specifying a generator, aka a build tool. For example, to build Wireshark using Ninja in the directory wireshark-ninja you might run the following commands:
# Starting from your Wireshark source directory, create a build directory # alongside it. $ cd .. $ mkdir wireshark-ninja $ cd wireshark-ninja # Assumes your source directory is named "wireshark". $ cmake -G Ninja ../wireshark $ ninja (or cmake --build .)
Using CMake on Windows is described further in Section 2.2.1.12, “Generate the build files”.
Along with specifying a generator with the -G
flag you can set variables
using the -D
flag. Useful variables and generators include the following:
tools/macos-setup.sh -t 10.14
.
You can list all build variables (with help) by running cmake -LH [options]
../<Name_of_WS_source_dir>
. This lists the cache of build variables
after the cmake run. To only view the current cache, add option -N
.
Depending on your needs, it might be useful to save your CMake configuration options in a file outside your build directory.
CMake supports this via its presets option.
For example, adding the following to CMakeUserPresets.json
would let you build using Ninja in the build
directory, enable ccache, and set a custom Qt directory by running cmake --preset mydev
:
{ "version": 4, "configurePresets": [ { "name": "mydev", "displayName": "Local development", "generator": "Ninja", "binaryDir": "${sourceDir}/build", "cacheVariables": { "ENABLE_CCACHE": "ON" }, "environment": { "CMAKE_PREFIX_PATH": "/usr/local/Qt6" } } ] }
After running cmake, you can always run make help
to see a list of all possible make targets.
Note that CMake honors user umask for creating directories as of now. You should set
the umask explicitly before running the install
target.
CMake links:
The home page of the CMake project: https://cmake.org/
Official documentation: https://cmake.org/documentation/
About CMake in general and why KDE4 uses it: https://lwn.net/Articles/188693/
Useful variables: https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/Useful-Variables
Frequently Asked Questions: https://gitlab.kitware.com/cmake/community/wikis/FAQ