Home page logo

wireshark logo Wireshark mailing list archives

Re: CMake for Windows
From: Graham Bloice <graham.bloice () trihedral com>
Date: Wed, 26 Jun 2013 10:35:26 +0100

On 26 June 2013 10:10, Roland Knall <rknall () gmail com> wrote:


As I am somewhat converse in cmake, I can give you a few pointers, if you

In general for each package a cmake system should look for, a
Find<PackageName>.cmake file should exist in either one of two places:

- The local directory (in wireshark underneath <src>/cmake/modules/Find....
- Or the global cmake directory <cmake_install_dir>/Modules/Find...

Those packages usually comply to a definition, where you can provide a
searchpath by setting a directory before including the package.

So if you have a CMakeLists.txt with the following context:




then you can set a search path by using:

    SET(ZLIB_INCLUDE_DIRS "c:\\wireshark-win32-libs\\zlib125\\include")
    SET(ZLIB_LIBRARY_DIRS "c:\\wireshark-win32-libs\\zlib125\\bin"
"c:\\wireshark-win32-libs\\zlib125\\lib" )

But setting static routes should be avoided, so better set a relative
path (aka ${PROJECT_BINARY_DIR}/../..) or
using a system variable.

If you have to call a script, you should do this by using either
EXECUTE_PROCESS or better create a CUSTOM_TARGET which you can depend
on, so that the right libraries will allways be downloaded, if they
cannot be found.

Finally, if you include user-editable scripts, they should start with
CMake...... and end in .txt. Something like config.CMake should be
avoided, as it is nmake specific.

kind regards,

I've been attempting that sort of thing but success eludes me.

Take cares for instance.  The path to the include dir is

I don't want to hard-code the library version suffix so I'd like to get
CMake to search within $(PROJECT_LIB_DIR) for a directory that begins

My current attempt is (with hard-coded paths and debugging messages):

IF (WIN32)
  MESSAGE("Searching wireshark libs for c-ares")
  FILE(GLOB subdir "W:/Wireshark/wireshark-win32-libs/*")
  FOREACH(dir $(subdir))
    MESSAGE("Found: $(dir)")
    IF(IS_DIRECTORY $(dir))
      MESSAGE("Found: $(dir)")
      IF("$(dir)" MATCHES "^c-ares-.*")
        SET(CARES_HINTS $(dir))

This fails to find any subdirectories at all.  I've also tried GLOB_RECURSE
with no change.

Sent via:    Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives:    http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request () wireshark org?subject=unsubscribe

  By Date           By Thread  

Current thread:
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]