[CMake] How to get find_package(ZLIB) to set ZLIB_LIBRARIES to 32-bit version ?
Rolf Eike Beer
eike at sf-mail.de
Wed Jun 25 02:18:52 EDT 2014
Am Dienstag, 24. Juni 2014, 22:32:22 schrieb Glenn Coombs:
> 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).
That means that CMake doesn't know that it is building a 32 bit executable,
which is a bad idea for reasons you already discovered. Try CC="gcc -m32"
cmake ... in a clean build tree.
Eke
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140625/c1561823/attachment.sig>
More information about the CMake
mailing list