1 Explain the cmake build system for wireshark
5 To find out the current state of the cmake implementation for
6 Wireshark, please take a look at "What needs to be done?" below.
11 How to get started with cmake (Unix/Linux and Win32/64)?
14 What needs to be done?
17 How to get started with cmake (Unix/Linux and Win32/64)?
18 ========================================================
20 You can find documentation on cmake at: http://www.cmake.org/
22 cmake is designed to support out of tree builds. So much so, that
23 in tree builds do not work properly in all cases.
25 How to do out of tree build (Unix/Linux):
27 2) Assuming, you are in the top directory of the wireshark source
31 5) cmake [options] ../<Name_of_WS_source_dir>
32 6) make (or cmake --build .)
33 7) (as root) umask 0022 && make install
36 In step 5) you may need to override the defaults for features. Common
39 # Disable the POSIX capabilities check
42 # Enable debugging symbols
43 -DCMAKE_BUILD_TYPE=Debug
49 -DENABLE_HTML_GUIDES=ON
50 -DENABLE_PDF_GUIDES=ON
52 # Make ccache and clang work together
53 -DCMAKE_C_FLAGS='-Qunused-arguments'
55 # Force Python path on Windows. May be needed if Cygwin's
56 # /usr/bin/python is present and is a symlink
57 # http://public.kitware.com/Bug/view.php?id=13818
58 -DPYTHON_EXECUTABLE=c:/Python27/python
60 # Disable building an application bundle (Wireshark.app) on macOS
61 -DENABLE_APPLICATION_BUNDLE=OFF
63 # Qt Creator expects .cbp files when used with CMake.
64 -G "CodeBlocks - Unix Makefiles"
65 -G "CodeBlocks - NMake Makefiles"
67 # We call try_compile many times, particularly via ConfigureChecks.cmake.
68 # Setting a lightweight try_compile configuration can speed up cmake,
69 # particularly for MSBuild.
70 -DCMAKE_TRY_COMPILE_CONFIGURATION=Release
72 You can list all build variables (with help) using
73 cmake -LH [options] ../<Name_of_WS_source_dir>
74 This lists the cache of build variables after the cmake run.
75 To only view the current cache, add option -N.
78 After running cmake, you can always run "make help" to see
79 a list of all possible make targets.
82 Cmake honors user umask for creating directories as of now:
83 http://public.kitware.com/Bug/view.php?id=9620
84 To get predictable results please set umask explicitly.
86 How to do an out of tree build using Visual C++ 2013:
87 [This is used for the 2.x release builds, support for VS2010 and VS2012
88 is included, but hasn't been tested.]
89 0) Install cmake (currently 3.1.3 or later is recommended). You can use chocolatey,
91 1) Follow https://www.wireshark.org/docs/wsdg_html_chunked/ChSetupWin32.html
93 1a) Set the library search path.
94 If you set WIRESHARK_BASE_DIR,
95 %WIRESHARK_BASE_DIR%\wireshark-%WIRESHARK_TARGET_PLATFORM%-libs will
96 be used as the top-level library directory.
97 If you set WIRESHARK_LIB_DIR, it will be used as the top-level library
98 directory. This definition will require changing for different builds (x86 & x64).
99 1b) set WIRESHARK_TARGET_PLATFORM=win32 (or win64)
100 1c) set QT5_BASE_DIR=C:\Qt\5.4.1\5.4\msvc2013_opengl (must match the Qt component path
102 1d) If you want to use Visual Studio to build rather than msbuild from the command line,
103 make sure that the path to Cygwin is available to GUI applications.
104 2) mkdir c:\wireshark\build or as appropriate for you.
105 You will need one build directory for each bitness (win32, win64) you wish to build.
106 3) cd into the directory from 2) above.
107 4) Run the following to generate the build files:
108 cmake -DENABLE_CHM_GUIDES=on xxx path\to\sources
109 where path\to\sources is the absolute or relative path to the wireshark source tree
110 and xxx is replaced with one of the following:
111 nothing - This will build a VS solution for win32 using the latest version of VS found (preferred).
112 -G "Visual Studio 12" ("12" builds for VS2013. Use "11" for VS2012 or "10" for VS2010.)
113 -G "NMake Makefiles" - to build an nmake makefile.
114 -G "Visual Studio 12 Win64" (to build an x64 version you must add the "Win64", Win32 is the default)
115 5) Run one of the following to build Wireshark:
116 msbuild /m /p:Configuration=RelWithDebInfo wireshark.sln (preferred).
117 Open Wireshark.sln in Windows Explorer to build in Visual Studio
118 nmake /X- VERBOSE=1 (or cmake --build . -- VERBOSE=1 ) (if you generated nmake files).
119 Subsequent changes to source files and CMakeLists.txt will be automagically detected
120 and new build files generated, i.e. step 4) doesn't need to be run again.
121 Changes to the build environment, e.g. QT_BASE_DIR aren't detected so you must delete the
122 build dir and start form step 2) again.
123 6) The executables can be run from the appropriate directory, e.g. run\RelWithDebInfo for VS solutions
124 or run\ for NMake files.
125 On macOS CMake creates an application bundle by default and places executables in
126 run/Wireshark.app/Contents/MacOS. It also creates a convenience wrapper script
127 (run/wireshark) which will run the Wireshark executable in the bundle.
128 7) To build an installer, build the nsis_package_prep and then the nsis_package projects, e.g.
129 msbuild /m /p:Configuration=RelWithDebInfo nsis_package_prep.vcxproj
130 msbuild /m /p:Configuration=RelWithDebInfo nsis_package.vcxproj
135 - Can create project files for many IDEs including Qt Creator, Visual Studio,
137 - Fast, builds in parallel in Visual Studio or msbuild with the /m flag
138 - Easier to understand/learn
139 - Doesn't create any files in the source tree in case of out of tree builds
140 - One build infrastructure for all of our tier 1 platforms (including Windows)
141 - Out of tree builds permits both Win32 and Win64 builds without requiring a "clean" when swapping.
146 - Everyone who wants to build from source needs cmake
147 - Current state of documentation isn't really better than
148 Autotools documentation. In some respects it's even worse
149 (you need to buy a book to get an explanation as to how
156 All the executables now build from clean source on:
157 * 32 bit openSUSE 11.3: (gnu)make and gcc
160 * 32 bit Ubuntu 10.04
161 * 64 bit Ubuntu 14.04
162 * 64 bit Debian Wheezy
164 * 64 bit {Mac} OS X/macOS
165 * 32 bit Windows using Visual C++ 2013
166 * 64 bit Windows using Visual C++ 2013
169 The Buildbot runs CMake steps on Ubuntu, Win32, Win64, macOS, and Solaris.
170 Windows packages are built using CMake steps.
172 What needs to be done?
173 ======================
175 - Add back platform specific objects.
176 - Fix places in the cmake files marked as todo.
177 - Guides are not installed.
178 - Build source package (using CPack).
179 This is obsolete if we decide to release VCS snapshots instead
180 - Build packages using CPack: tarball, Windows installer + PortableApps, macOS
181 installer dmg, RPM, SVR4. This includes setting OS target version stuff
182 appropriately for macOS. We currently use NSIS for the Windows installer but
183 should probably use WiX instead.
184 - Add support for cmake configurations.
185 - Get cross-compilation working (or ensure it does). It works with autofoo--and
187 - Handle -DFORTIFY_SOURCE=2 appropriately. (Do a Web search for
188 "cmake fortify" for some information.)
189 - Define the GTK_DISABLE_ and GDK_DISABLE_ values as appropriate if we
190 care about supporting the GTK+ version.
193 Links regarding cmake
194 =====================
195 The home page of the cmake project
196 http://www.cmake.org/
198 The home page of the cmake project documentation
199 http://www.cmake.org/Wiki/CMake
201 About cmake in general and why KDE4 uses it
202 http://lwn.net/Articles/188693/
204 Introductory/tutorial presentation
205 http://ait.web.psi.ch/services/linux/hpc/hpc_user_cookbook/tools/cmake/docs/Cmake_VM_2007.pdf
207 Introductory article in Linux Journal
208 http://www.linuxjournal.com/node/6700/print
211 http://www.cmake.org/Wiki/CMake_Useful_Variables
214 http://www.cmake.org/Wiki/CMake_FAQ
216 Additional cmake modules
217 http://code.google.com/p/cmake-modules/