[CMake] How to get find_package(ZLIB) to set ZLIB_LIBRARIES to 32-bit version ?

Glenn Coombs glenn.coombs at gmail.com
Tue Jun 24 17:32:22 EDT 2014


This seems to be the recommended way to link against the zlib library:

find_package(ZLIB)if (ZLIB_FOUND)
    include_directories(${ZLIB_INCLUDE_DIRS})
    target_link_libraries(MyProg ${ZLIB_LIBRARIES})
endif()

When I run this on linux I see that ZLIB_LIBRARIES has the value
/usr/lib64/libz.so.  On this machine gcc creates 64-bit binaries by
default.  In my CMakeLists.txt I have an option for building 32-bit which
adds "-m32" to the compiler and linker command lines.  However the
ZLIB_LIBRARIES variable is still returning the 64-bit version
(/usr/lib64/libz.so) instead of the 32-bit version (/usr/lib/libz.so).

Is there some way for me to let cmake know that I'm building 32-bit so that
the find_package(ZLIB) command sets ZLIB_LIBRARIES to the correct 32-bit
version of the library ?

--
Glenn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140624/7e2cc887/attachment.html>


More information about the CMake mailing list