Link libbz2 statically to fix a problem running a copy of the updater built on a Debian system on a RedHat-based system.

Under Debian, the libbz2.so SONAME is libbz2.so.1.0, so ld links to this
version of libbz2.  Debian has symlinks from libbz2.so.1 and libbz2.so.1.0 to
libbz2.so.1.0.x.  RedHat however does not have the libbz2.so.1.0 symlink
so linking fails at runtime.

This commit fixes the problem by linking to libbz2 statically on Linux.
This does not bloat the updater library too much as libbz2 is only 70K
(measured on Ubuntu 11.04).
This commit is contained in:
Robert Knight 2011-10-03 11:49:26 +01:00
parent 60357cada9
commit addc3b253d
1 changed files with 13 additions and 1 deletions

View File

@ -33,7 +33,19 @@ add_library(minizip
)
if (UNIX)
target_link_libraries(minizip z bz2)
# on Mac, link to libbz2 dynamically, on Linux
# we link statically to libbz2 so that an updater binary
# build on Debian (where the packaged libbz2 has a SONAME of "libbz2.so.1.0"
# works on Fedora/openSUSE (where no libbz2.so.1.0 symlink exists)
#
# see http://stackoverflow.com/questions/1835489/linking-an-application-to-libbz2-so-1-rather-than-libbz2-so-1-0
#
set(BZ2_LIB_NAME bz2)
if (NOT APPLE)
set(BZ2_LIB_NAME bz2.a)
endif()
target_link_libraries(minizip z ${BZ2_LIB_NAME})
else()
target_link_libraries(minizip
"${CMAKE_CURRENT_SOURCE_DIR}/../zlib/prebuilt/zlib_static.lib"