List Archive


Thread Index


From: Andreas Falkenhahn <>
To: Thomas Klausner <>
Subject: Re: Setting zlib path when compiling on Windows
Date: Mon, 2 Oct 2017 23:34:50 +0200

On 02.10.2017 at 23:27 Thomas Klausner wrote:

> On Mon, Oct 02, 2017 at 10:51:25PM +0200, Andreas Falkenhahn wrote:
>> I'm trying to compile libzip on Windows using CMake to generate
>> makefiles. Libzip needs zlib so I'm doing the following:

>>       mkdir build
>>       cd build
>>       cmake -DZLIB_LIBRARY=../../../zlib-1.2.11 
>> -DZLIB_INCLUDE_DIR=../../../zlib-1.2.11 ..

>> This doesn't work, however. I get the following error:

>>       CMake Error at C:/Program Files 
>> (x86)/CMake/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:138 
>> (message):
>>       Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)

>> Why is that? I have defined ZLIB_LIBRARY and ZLIB_INCLUDE_DIR to point
>> to the latest zlib.

>> I've also tried the following:

>>       mkdir build
>>       cd build
>>       cmake .. -DZLIB_LIBRARY=../../../zlib-1.2.11 
>> -DZLIB_INCLUDE_DIR=../../../zlib-1.2.11

>> When I run CMake like this, I get the following two warnings:

>>       CMake Warning:
>>       Manually-specified variables were not used by the project:

>> In comparison to the first approach, however, build files are now written to 
>> my build
>> directory. When running nmake, however, only zlib seems to get built. libzip 
>> itself
>> isn't built at all.

> This confuses me. We do not distribute infrastructure to build zlib.
> zlib needs to be built first separately.

Well, CMake probably fetches CMakeLists.txt from the zlib directory
and then just builds CMake...

>> I'm out of ideas here. What am I doing wrong?

> When I run it locally (just 'cmake ..', and on NetBSD, not Linux) I get

> ZLIB_INCLUDE_DIR:PATH=/usr/include

> in my CMakeCache.txt file. So it seems that ZLIB_LIBRARY might have to
> point to the actual library and not a directory.

Keep in mind that I'm on Windows. This is the actual problem here :)
Of course on Linux and Mac zlib is already installed but on Windows
I need to point CMake to zlib explicitly. But currently I'm failing
to see how to do that as all my approaches have failed so far.

Your suggestion of setting ZLIB_LIBRARY to the actual library
instead of a directory also doesn't help because I aim to link
statically against both libzip and zlib so all libzip should
actually need is access to the zlib headers but I don't see
how to pass that path to CMake...

Best regards,
 Andreas Falkenhahn                   

Made by MHonArc.