[CMake] CMake Visual Studio zlib zlibstatic.lib

Robin Mills robin at clanmills.com
Sat Sep 16 03:39:51 EDT 2017


Folks

My project (exiv2.org <http://exiv2.org/>) uses zlib and is builds well on all platforms (Linux,
Cygwin, MacOS-X and Visual Studio) with CMake.

A user complained that the CMake/Visual Studio static builds link zlib.dll
(zlibd.dll for debug) and wants to link zlibstatic.lib (zlibstaticd.lib). 
I've tracked this down to FindZlib.cmake which sets ZLIB_FOUND,
ZLIB_LIBRARIES and ZLIB_INCLUDE_DIRS to use the zlib dynamic libraries.  For
the moment, I have a work-around which externally copies zlibstatic.lib to
overwrite zlib.lib.

I've inspected the code in FindZlib.cmake and it doesn't appear to know
about zlibstatic.  I've unsuccessfully tried to use string(REPLACE ...) on
ZLIB_LIBRARIES.  I don't know CMake very well.  Is ZLIB_LIBRARIES a string
or a list of strings?  How can I either edit it, or get a new variable
ZLIB_STATIC_LIBRARIES to pass to target_link_libraries(...)

Any suggestions?  All help appreciated.

Robin Mills
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170916/2531fcbf/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Exiv2Logo.png
Type: image/png
Size: 49689 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170916/2531fcbf/attachment-0001.png>


More information about the CMake mailing list