Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: Re: [Wireshark-dev] Status Cmake Win32 support

From: Graham Bloice <graham.bloice@xxxxxxxxxxxxx>
Date: Tue, 26 Nov 2013 21:42:27 +0000
On 26 November 2013 12:15, Joerg Mayer <jmayer@xxxxxxxxx> wrote:
Just a short note on this one, the rest after work and some testing :-)

On Sun, Nov 24, 2013 at 09:51:47PM +0000, Graham Bloice wrote:
> The above fix for gtkui then broke wiretap, and some other things, e.g.
> dumpcap, as it was picking up the gtk3 version of zlib.h, which included
> zconf.h which attempted to include unistd.h.  To fix this I modified the
> CMakeLists.txt for the affect items to put the ZLIB libraries in front of
> the GLIB ones.  This works for everything except wireshark itself.  Try as
> I might, I can't persuade CMake to put the zlib includes in front of the
> gtk-3.0 ones, the library is, but not the includes.  Manually hacking the
> wireshark.vcxproj file does allow it to build, so I'm close.

I have solved this on my system for both gtk2 and gtk3 by manually changing
gtk[23]/include/zconf.h to
#if 0    /* was set to #if 1 by ./configure */
#  define Z_HAVE_UNISTD_H
#endif

After that things worked.

Ciao
    Jörg


I have a fix for the zlib issue, not sure if it's acceptable though. In CMakeLists.txt, epan\CMakeLists.txt and wiretap\CMakeLists.txt, add "include_directories(BEFORE ${ZLIB_INCLUDE_DIRS})" before the first "add_executable" or "add_library" instruction.  This forces the zlib include dir to the front of all subsequent compiles for the generator.

I tried all sorts of ways to get zlib to the front but it appears the VS solution generator will always sort the includes alphabetically unless there is a BEFORE option.  I'd hoped to do this in the FindZLib.cmake module but the incantations are beyond me.