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