Update READMEs to reflect recent CMake environment changes.
[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    Basically this is an experiment and if we find out that it works
8    and we like cmake more than autofoo we might switch one day.
9
10 Table of contents
11 =================
12
13 How to get started with cmake (Unix/Linux and Win32/64)?
14 Why cmake?
15 Why not cmake?
16 What needs to be done?
17 Links regarding cmake
18
19 How to get started with cmake (Unix/Linux and Win32/64)?
20 ========================================================
21
22 You can find documentation on cmake at: http://www.cmake.org/
23
24 cmake is designed to support out of tree builds. So much so, that
25 in tree builds do not work properly in all cases.
26
27 How to do out of tree build (Unix/Linux):
28 1) Install cmake.
29 2) Assuming, you are in the top directory of the wireshark source
30    cd ..
31 3) mkdir build
32 4) cd build
33 5) cmake [options] ../<Name_of_WS_source_dir>
34 6) make (or cmake --build .)
35 7) (as root) umask 0022 && make install
36
37 Note 1:
38   In step 5) you may need to override the defaults for features. Common
39   options include:
40
41   # Disable the POSIX capbabilities check
42   -DENABLE_CAP=OFF
43
44   # Enable debugging symbols
45   -DCMAKE_BUILD_TYPE=Debug
46
47   # Disable GTK+ 3
48   -DENABLE_GTK3=OFF
49
50   # Build documentation
51   -DENABLE_GUIDES=ON
52
53   # Make ccache and clang work together
54   -DCMAKE_C_FLAGS='-Qunused-arguments'
55
56   # Force Python path on Windows. May be needed if Cygwin's
57   # /usr/bin/python is present and is a symlink
58   # http://public.kitware.com/Bug/view.php?id=13818
59   -DPYTHON_EXECUTABLE=c:/Python27/python
60
61   # Disable building an application bundle (Wireshark.app) on Mac OS X
62   -DENABLE_APPLICATION_BUNDLE=OFF
63
64 Note 2:
65   After running cmake, you can always run "make help" to see
66   a list of all possible make targets.
67
68 Note 3:
69   Cmake honors user umask for creating directories as of now:
70   http://public.kitware.com/Bug/view.php?id=9620
71   To get predictable results please set umask explicitly.
72
73 How to do an out of tree build using Visual C++ 2013:
74 [This is advanced alpha and should build all executables except the GTK3
75  Wireshark for 32-bit.]
76 1) Follow http://www.wireshark.org/docs/wsdg_html_chunked/ChSetupWin32.html
77    Steps 1-9
78 1a) Set WIRESHARK_BASE_DIR=c:\wireshark (the parent directory of the
79    library directory).
80 1b) set WIRESHARK_TARGET_PLATFORM=win32 (or win64)
81 1c) set QT5_BASE_DIR=C:\Qt\5.3\msvc2013_opengl (must match the Qt component path
82     on your system)
83 1d) If you want to use Visual Studio make sure that the paths to Python and
84     Cygwin are available to GUI applications. The Python path MUST come first.
85 2) Install cmake
86 2a) Build the zlib library, e.g.
87     cd %WIRESHARK_BASE_DIR%\wireshark-%WIRESHARK_TARGET_PLATFORM%-libs\zlib125
88     cmake -G "NMake Makefiles" . # msbuild will not do because of configuration path
89     cmake --build .
90 3) mkdir c:\wireshark\build
91 4) cd c:\wireshark\build
92 5) Run one of the following to create the build environment:
93    cmake -G "NMake Makefiles" path\to\sources  (i.e. in case your sources are located at c:\wireshark\trunk, use "..\trunk")
94    cmake path\to\sources (this will build for the latest Visual Studio version found)
95    cmake -G "Visual Studio 12" ("12" builds for VS2103. Use "11" for VS2012 or "10" for VS2010.)
96    cmake -G "Visual Studio 12 Win64" (Win32 is the default)
97 6) Run one of the following to build Wireshark:
98    nmake /X- VERBOSE=1 (or cmake --build . -- VERBOSE=1 )
99    Open Wireshark.sln in Windows Explorer to build in Visual Studio
100    msbuild wireshark.sln /m /p:Configuration=RelWithDebInfo
101 7) In case you want to test the executable(s) inside the build tree:
102    Run setpath.bat whenever it gets updated (there is a message in each cmake
103    run whether it is necessary or not).
104
105 Why cmake?
106 ==========
107 - Can create project files for many IDEs including Qt Creator, Visual Studio,
108   and XCode.
109 - Fast
110 - Easier to understand/learn
111 - Doesn't create any files in the source tree in case of out of tree builds
112 - One build infrastructure for all of our tier 1 platforms (including Windows)
113
114 Why not cmake?
115 ==============
116 - Lots of work to do
117 - Everyone who wants to build from source needs cmake
118 - Current state of documentation isn't really better than
119   Autotools documentation. In some respects it's even worse
120   (you need to buy a book to get an explanation as to how
121   cmake really works).
122 ...
123
124 What works?
125 ===========
126
127 All the executables now build from clean source on:
128 * 32 bit openSUSE 11.3: (gnu)make and gcc
129 * 64 bit FedoraXXX
130 * 32 bit Ubuntu 9.04
131 * 32 bit Ubuntu 10.04
132 * 64 bit Ubuntu 14.04
133 * 64 bit Debian Wheezy
134 * 32 bit OS X
135 * 64 bit OS X
136 * 32 bit Windows using Visual C++ 2013
137 * 64 bit Windows using Visual C++ 2013
138 * 64 bit Solaris 10
139
140 The Buildbot runs CMake steps on Ubuntu, Win32, Win64, OS X, and Solaris.
141
142 What needs to be done?
143 ======================
144
145 - Add back platform specific objects.
146 - Fix places in the cmake files marked as todo.
147 - Guides are not installed.
148 - Build source package (using CPack).
149   This is obsolete if we decide to release VCS snapshots instead
150 - Build packages using CPack: tarball, Windows installer + PortableApps, OS X
151   installer dmg, RPM, SVR4. This includes setting OS target version stuff
152   appropriately for OS X. We currently use NSIS for the Windows installer but
153   should probably use WiX instead.
154 - Add back checkAPI target.
155 - Add support for cmake configurations.
156 - Automatically figure out if *shark is running from the build directory
157   (making WIRESHARK_RUN_FROM_BUILD_DIRECTORY unnecessary like it is with
158   autofoo).
159   Sadly:
160
161       $ file run/qtshark
162       run/qtshark: Mach-O 64-bit x86_64 executable
163
164   so what you're running from the build directory is the executable
165   itself.  autofoo includes libtool in our case, so what you're running
166   from the build directory is a script that then runs the executable,
167   and the executable is in a .libs directory; the code that checks for
168   "running from the build directory?" checks for that.
169
170   We could perhaps check for the pathname containing "run/", although
171   that wouldn't help if we ran it while *in* the "run" directory;
172   getting an absolute path for the executable would be necessary for
173   that.
174 - Get plugins loading when running *shark from the build directory.
175   That might involve handling ".libs" and "run" differently.
176 - Get cross-compilation working (or ensure it does). It works with autofoo.
177 - Handle -DFORTIFY_SOURCE=2 appropriately.  (Do a Web search for
178   "cmake fortify" for some information.)
179 - Add support for Visual Studio code anlaysis similar to ENABLE_CODE_ANALYSIS in
180   config.nmake.
181 - Define the GTK_DISABLE_ and GDK_DISABLE_ values as appropriate if we
182   care about supporting the GTK+ version.
183 ...
184
185 Links regarding cmake
186 =====================
187 The home page of the cmake project
188         http://www.cmake.org/
189
190 The home page of the cmake project documentation
191         http://www.cmake.org/Wiki/CMake
192
193 About cmake in general and why KDE4 uses it
194         http://lwn.net/Articles/188693/
195
196 Introductory/tutorial presentation
197         http://ait.web.psi.ch/services/linux/hpc/hpc_user_cookbook/tools/cmake/docs/Cmake_VM_2007.pdf
198
199 Introductory article in Linux Journal
200         http://www.linuxjournal.com/node/6700/print
201
202 Useful variables
203         http://www.cmake.org/Wiki/CMake_Useful_Variables
204
205 cmake FAQ
206         http://www.cmake.org/Wiki/CMake_FAQ
207
208 Additional cmake modules
209         http://code.google.com/p/cmake-modules/