[GTPv2] Throttling Delay unit values are not the same as the timer values,
[metze/wireshark/wip.git] / README.cmake
1           Explain the cmake build system for wireshark
2
3                            Notice
4
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.
7
8 Table of contents
9 =================
10
11 How to get started with cmake (Unix/Linux and Win32/64)?
12 Why cmake?
13 Why not cmake?
14 What needs to be done?
15 Links regarding cmake
16
17 How to get started with cmake (Unix/Linux and Win32/64)?
18 ========================================================
19
20 You can find documentation on cmake at: http://www.cmake.org/
21
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.
24
25 How to do out of tree build (Unix/Linux):
26 1) Install cmake.
27 2) Assuming, you are in the top directory of the wireshark source
28    cd ..
29 3) mkdir build
30 4) cd build
31 5) cmake [options] ../<Name_of_WS_source_dir>
32 6) make (or cmake --build .)
33 7) (as root) umask 0022 && make install
34
35 Note 1:
36   In step 5) you may need to override the defaults for features. Common
37   options include:
38
39   # Disable the POSIX capbabilities check
40   -DENABLE_CAP=OFF
41
42   # Enable debugging symbols
43   -DCMAKE_BUILD_TYPE=Debug
44
45   # Disable GTK+ 3
46   -DENABLE_GTK3=OFF
47
48   # Build documentation
49   -DENABLE_HTML_GUIDES=ON
50   -DENABLE_PDF_GUIDES=ON
51
52   # Make ccache and clang work together
53   -DCMAKE_C_FLAGS='-Qunused-arguments'
54
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
59
60   # Disable building an application bundle (Wireshark.app) on Mac OS X
61   -DENABLE_APPLICATION_BUNDLE=OFF
62
63 Note 2:
64   After running cmake, you can always run "make help" to see
65   a list of all possible make targets.
66
67 Note 3:
68   Cmake honors user umask for creating directories as of now:
69   http://public.kitware.com/Bug/view.php?id=9620
70   To get predictable results please set umask explicitly.
71
72 How to do an out of tree build using Visual C++ 2013:
73 [This is at rc status and should build all executables, support for VS2010 and VS2012
74  is included, but hasn't been tested.]
75 0) Install cmake (currently 3.1.3 or later is recommended).  You can use chocolatey,
76    choco inst cmake.
77 1) Follow https://www.wireshark.org/docs/wsdg_html_chunked/ChSetupWin32.html
78    Steps 1-9
79 1a) Set the library search path.
80     If you set WIRESHARK_BASE_DIR,
81     %WIRESHARK_BASE_DIR%\wireshark-%WIRESHARK_TARGET_PLATFORM%-libs will
82     be used as the top-level library directory.
83     If you set WIRESHARK_LIB_DIR, it will be used as the top-level library
84     directory.  This definition will require changing for different builds (x86 & x64).
85 1b) set WIRESHARK_TARGET_PLATFORM=win32 (or win64)
86 1c) set QT5_BASE_DIR=C:\Qt\5.4.1\5.4\msvc2013_opengl (must match the Qt component path
87     on your system)
88 1d) If you want to use Visual Studio to build rather than msbuild from the command line,
89     make sure that the paths to Python and Cygwin are available to GUI applications.
90     The Python path MUST come first.
91 2) mkdir c:\wireshark\build or as appropriate for you.
92    You will need one build directory for each bitness (win32, win64) you wish to build.
93 3) cd into the directory from 2) above.
94 4) Run the following to generate the build files:
95    cmake -DPYTHON_EXECUTABLE=/path/to/python -DENABLE_CHM_GUIDES=on xxx path\to\sources
96    where /path/to/python is the path to your Windows python executable, e.g. C:/Python27/python
97    and path\to\sources is the absolute or relative path to the wireshark source tree
98    and xxx is replaced with one of the following:
99        nothing - This will build a VS solution for win32 using the latest version of VS found (preferred).
100        -G "Visual Studio 12" ("12" builds for VS2013. Use "11" for VS2012 or "10" for VS2010.)
101        -G "NMake Makefiles" - to build an nmake makefile.
102        -G "Visual Studio 12 Win64" (Win32 is the default)
103 5) Run one of the following to build Wireshark:
104    msbuild /m /p:Configuration=RelWithDebInfo wireshark.sln (preferred).
105    Open Wireshark.sln in Windows Explorer to build in Visual Studio
106    nmake /X- VERBOSE=1 (or cmake --build . -- VERBOSE=1 ) (if you generated nmake files).
107    Subsequent changes to source files and CMakeLists.txt will be automagically detected
108    and new build files generated, i.e. step 4) doesn't need to be run again.
109    Changes to the build environment, e.g. QT_BASE_DIR aren't detected so you must delete the
110    build dir and start form step 2) again.
111 6) The executables can be run from the appropriate directory, e.g. run\RelWithDebInfo for VS solutions
112    or run\ for NMake files.
113 7) To build an installer, build the nsis_package project, e.g.
114    msbuild /m /p:Configuration=RelWithDebInfo nsis_package.vcxproj
115    nmake ???
116
117 Why cmake?
118 ==========
119 - Can create project files for many IDEs including Qt Creator, Visual Studio,
120   and XCode.
121 - Fast
122 - Easier to understand/learn
123 - Doesn't create any files in the source tree in case of out of tree builds
124 - One build infrastructure for all of our tier 1 platforms (including Windows)
125
126 Why not cmake?
127 ==============
128 - Lots of work to do
129 - Everyone who wants to build from source needs cmake
130 - Current state of documentation isn't really better than
131   Autotools documentation. In some respects it's even worse
132   (you need to buy a book to get an explanation as to how
133   cmake really works).
134 ...
135
136 What works?
137 ===========
138
139 All the executables now build from clean source on:
140 * 32 bit openSUSE 11.3: (gnu)make and gcc
141 * 64 bit FedoraXXX
142 * 32 bit Ubuntu 9.04
143 * 32 bit Ubuntu 10.04
144 * 64 bit Ubuntu 14.04
145 * 64 bit Debian Wheezy
146 * 32 bit OS X
147 * 64 bit OS X
148 * 32 bit Windows using Visual C++ 2013
149 * 64 bit Windows using Visual C++ 2013
150 * 64 bit Solaris 10
151
152 The Buildbot runs CMake steps on Ubuntu, Win32, Win64, OS X, and Solaris.
153 Windows packages are built using CMake steps.
154
155 What needs to be done?
156 ======================
157
158 - Add back platform specific objects.
159 - Fix places in the cmake files marked as todo.
160 - Guides are not installed.
161 - Build source package (using CPack).
162   This is obsolete if we decide to release VCS snapshots instead
163 - Build packages using CPack: tarball, Windows installer + PortableApps, OS X
164   installer dmg, RPM, SVR4. This includes setting OS target version stuff
165   appropriately for OS X. We currently use NSIS for the Windows installer but
166   should probably use WiX instead.
167 - Add support for cmake configurations.
168 - Automatically figure out if *shark is running from the build directory
169   (making WIRESHARK_RUN_FROM_BUILD_DIRECTORY unnecessary like it is with
170   autofoo).
171   Sadly:
172
173       $ file run/qtshark
174       run/qtshark: Mach-O 64-bit x86_64 executable
175
176   so what you're running from the build directory is the executable
177   itself.  autofoo includes libtool in our case, so what you're running
178   from the build directory is a script that then runs the executable,
179   and the executable is in a .libs directory; the code that checks for
180   "running from the build directory?" checks for that.  The actual
181   executable isn't supposed to be run directly - it's expected to be run
182   by the wrapper script and might not even work if run directly, as it
183   won't find the relevant shared libraries.
184
185   We could perhaps check for the executable being in a "run" directory
186   instead, if the build drops it there.  However, it's possible, at
187   least on OS X, to copy the executable to another directory and have
188   it run, so the guarantee that it's in a "run" directory is not as
189   strong.
190 - Get plugins loading when running *shark from the build directory.
191   That might involve handling ".libs" and "run" differently.  The chance
192   that a random directory the executable was ultimately placed in would
193   be named "run" might also be a bit bigger than the chance that it's
194   named ".libs".
195 - Get cross-compilation working (or ensure it does). It works with autofoo--and
196   people use it.
197 - Handle -DFORTIFY_SOURCE=2 appropriately.  (Do a Web search for
198   "cmake fortify" for some information.)
199 - Define the GTK_DISABLE_ and GDK_DISABLE_ values as appropriate if we
200   care about supporting the GTK+ version.
201 - Install the freedesktop integration files (wireshark.desktop,
202   wireshark-mime-package.xml, etc.).
203 ...
204
205 Links regarding cmake
206 =====================
207 The home page of the cmake project
208         http://www.cmake.org/
209
210 The home page of the cmake project documentation
211         http://www.cmake.org/Wiki/CMake
212
213 About cmake in general and why KDE4 uses it
214         http://lwn.net/Articles/188693/
215
216 Introductory/tutorial presentation
217         http://ait.web.psi.ch/services/linux/hpc/hpc_user_cookbook/tools/cmake/docs/Cmake_VM_2007.pdf
218
219 Introductory article in Linux Journal
220         http://www.linuxjournal.com/node/6700/print
221
222 Useful variables
223         http://www.cmake.org/Wiki/CMake_Useful_Variables
224
225 cmake FAQ
226         http://www.cmake.org/Wiki/CMake_FAQ
227
228 Additional cmake modules
229         http://code.google.com/p/cmake-modules/