Fix "disable this protocol by default".
[jlayton/wireshark.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 capabilities 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 OS X
61   -DENABLE_APPLICATION_BUNDLE=OFF
62
63   # Qt Creator expects .cbp files when used with CMake.
64   -G "CodeBlocks - Unix Makefiles"
65   -G "CodeBlocks - NMake Makefiles"
66
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
71
72 Note 2:
73   After running cmake, you can always run "make help" to see
74   a list of all possible make targets.
75
76 Note 3:
77   Cmake honors user umask for creating directories as of now:
78   http://public.kitware.com/Bug/view.php?id=9620
79   To get predictable results please set umask explicitly.
80
81 How to do an out of tree build using Visual C++ 2013:
82 [This is used for the 2.x release builds, support for VS2010 and VS2012
83  is included, but hasn't been tested.]
84 0) Install cmake (currently 3.1.3 or later is recommended).  You can use chocolatey,
85    choco inst cmake.
86 1) Follow https://www.wireshark.org/docs/wsdg_html_chunked/ChSetupWin32.html
87    Steps 1-9
88 1a) Set the library search path.
89     If you set WIRESHARK_BASE_DIR,
90     %WIRESHARK_BASE_DIR%\wireshark-%WIRESHARK_TARGET_PLATFORM%-libs will
91     be used as the top-level library directory.
92     If you set WIRESHARK_LIB_DIR, it will be used as the top-level library
93     directory.  This definition will require changing for different builds (x86 & x64).
94 1b) set WIRESHARK_TARGET_PLATFORM=win32 (or win64)
95 1c) set QT5_BASE_DIR=C:\Qt\5.4.1\5.4\msvc2013_opengl (must match the Qt component path
96     on your system)
97 1d) If you want to use Visual Studio to build rather than msbuild from the command line,
98     make sure that the path to Cygwin is available to GUI applications.
99 2) mkdir c:\wireshark\build or as appropriate for you.
100    You will need one build directory for each bitness (win32, win64) you wish to build.
101 3) cd into the directory from 2) above.
102 4) Run the following to generate the build files:
103    cmake -DENABLE_CHM_GUIDES=on xxx path\to\sources
104    where path\to\sources is the absolute or relative path to the wireshark source tree
105    and xxx is replaced with one of the following:
106        nothing - This will build a VS solution for win32 using the latest version of VS found (preferred).
107        -G "Visual Studio 12" ("12" builds for VS2013. Use "11" for VS2012 or "10" for VS2010.)
108        -G "NMake Makefiles" - to build an nmake makefile.
109        -G "Visual Studio 12 Win64" (to build an x64 version you must add the "Win64", Win32 is the default)
110 5) Run one of the following to build Wireshark:
111    msbuild /m /p:Configuration=RelWithDebInfo wireshark.sln (preferred).
112    Open Wireshark.sln in Windows Explorer to build in Visual Studio
113    nmake /X- VERBOSE=1 (or cmake --build . -- VERBOSE=1 ) (if you generated nmake files).
114    Subsequent changes to source files and CMakeLists.txt will be automagically detected
115    and new build files generated, i.e. step 4) doesn't need to be run again.
116    Changes to the build environment, e.g. QT_BASE_DIR aren't detected so you must delete the
117    build dir and start form step 2) again.
118 6) The executables can be run from the appropriate directory, e.g. run\RelWithDebInfo for VS solutions
119    or run\ for NMake files.
120 7) To build an installer, build the nsis_package_prep and then the nsis_package projects, e.g.
121    msbuild /m /p:Configuration=RelWithDebInfo nsis_package_prep.vcxproj
122    msbuild /m /p:Configuration=RelWithDebInfo nsis_package.vcxproj
123    nmake ???
124
125 Why cmake?
126 ==========
127 - Can create project files for many IDEs including Qt Creator, Visual Studio,
128   and XCode.
129 - Fast, builds in parallel in Visual Studio or msbuild with the /m flag
130 - Easier to understand/learn
131 - Doesn't create any files in the source tree in case of out of tree builds
132 - One build infrastructure for all of our tier 1 platforms (including Windows)
133 - Out of tree builds permits both Win32 and Win64 builds without requiring a "clean" when swapping.
134
135 Why not cmake?
136 ==============
137 - Lots of work to do
138 - Everyone who wants to build from source needs cmake
139 - Current state of documentation isn't really better than
140   Autotools documentation. In some respects it's even worse
141   (you need to buy a book to get an explanation as to how
142   cmake really works).
143 ...
144
145 What works?
146 ===========
147
148 All the executables now build from clean source on:
149 * 32 bit openSUSE 11.3: (gnu)make and gcc
150 * 64 bit FedoraXXX
151 * 32 bit Ubuntu 9.04
152 * 32 bit Ubuntu 10.04
153 * 64 bit Ubuntu 14.04
154 * 64 bit Debian Wheezy
155 * 32 bit OS X
156 * 64 bit OS X
157 * 32 bit Windows using Visual C++ 2013
158 * 64 bit Windows using Visual C++ 2013
159 * 64 bit Solaris 10
160
161 The Buildbot runs CMake steps on Ubuntu, Win32, Win64, OS X, and Solaris.
162 Windows packages are built using CMake steps.
163
164 What needs to be done?
165 ======================
166
167 - Add back platform specific objects.
168 - Fix places in the cmake files marked as todo.
169 - Guides are not installed.
170 - Build source package (using CPack).
171   This is obsolete if we decide to release VCS snapshots instead
172 - Build packages using CPack: tarball, Windows installer + PortableApps, OS X
173   installer dmg, RPM, SVR4. This includes setting OS target version stuff
174   appropriately for OS X. We currently use NSIS for the Windows installer but
175   should probably use WiX instead.
176 - Add support for cmake configurations.
177 - Get cross-compilation working (or ensure it does). It works with autofoo--and
178   people use it.
179 - Handle -DFORTIFY_SOURCE=2 appropriately.  (Do a Web search for
180   "cmake fortify" for some information.)
181 - Define the GTK_DISABLE_ and GDK_DISABLE_ values as appropriate if we
182   care about supporting the GTK+ version.
183 - Install the freedesktop integration files (wireshark.desktop,
184   wireshark-mime-package.xml, etc.).
185 ...
186
187 Links regarding cmake
188 =====================
189 The home page of the cmake project
190         http://www.cmake.org/
191
192 The home page of the cmake project documentation
193         http://www.cmake.org/Wiki/CMake
194
195 About cmake in general and why KDE4 uses it
196         http://lwn.net/Articles/188693/
197
198 Introductory/tutorial presentation
199         http://ait.web.psi.ch/services/linux/hpc/hpc_user_cookbook/tools/cmake/docs/Cmake_VM_2007.pdf
200
201 Introductory article in Linux Journal
202         http://www.linuxjournal.com/node/6700/print
203
204 Useful variables
205         http://www.cmake.org/Wiki/CMake_Useful_Variables
206
207 cmake FAQ
208         http://www.cmake.org/Wiki/CMake_FAQ
209
210 Additional cmake modules
211         http://code.google.com/p/cmake-modules/