From 58b04c5f21bdf1808debca57733251c344943be2 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 18 Aug 2020 13:57:59 +0800 Subject: [PATCH] cmake: link against ZLIB if statically linked agasint Boost Boost::iostreams links against zlib. and FindBoost.cmake does not add this linkage to Boost::iostreams target, let's do this after `find_package(Boost...)`. in theory, it'd be better to have this change in FindBoost.cmake, but it's error-prone, and increases the risk of regression when we sync our own copy of FindBoost.cmake with CMake upstream. ../../build.deps/mingw/boost/lib/libboost_iostreams.a(zlib.o):zlib.cpp:(.text+0xf7): undefined reference to `crc32' ../../build.deps/mingw/boost/lib/libboost_iostreams.a(zlib.o):zlib.cpp:(.text+0x165): undefined reference to `deflateReset'../../build.deps/mingw/boost/lib/libboost_iostreams.a(zlib.o):zlib.cpp:(.text+0x185): undefined reference to `inflateEnd' ../../build.deps/mingw/boost/lib/libboost_iostreams.a(zlib.o):zlib.cpp:(.text+0x1a1): undefined reference to `inflateReset'../../build.deps/mingw/boost/lib/libboost_iostreams.a(zlib.o):zlib.cpp:(.text+0x1b3): undefined reference to `deflateEnd' ../../build.deps/mingw/boost/lib/libboost_iostreams.a(zlib.o):zlib.cpp:(.text+0x38d): undefined reference to `inflateInit2_' ../../build.deps/mingw/boost/lib/libboost_iostreams.a(zlib.o):zlib.cpp:(.text+0x3d5): undefined reference to `deflateInit2_' ../../build.deps/mingw/boost/lib/libboost_iostreams.a(zlib.o):zlib.cpp:(.text+0x134): undefined reference to `deflate' ../../build.deps/mingw/boost/lib/libboost_iostreams.a(zlib.o):zlib.cpp:(.text+0x144): undefined reference to `inflate' collect2: error: ld returned 1 exit status src/CMakeFiles/ceph-common.dir/build.make:441: recipe for target 'bin/libceph-common.dll' failed Signed-off-by: Kefu Chai --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 88a87df6be1..28c09893342 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -593,6 +593,10 @@ if(WITH_SYSTEM_BOOST) set(BOOST_LIBRARYDIR "${BOOST_ROOT}/lib/${CMAKE_LIBRARY_ARCHITECTURE}") endif() find_package(Boost 1.67 COMPONENTS ${BOOST_COMPONENTS} REQUIRED) + if(NOT ENABLE_SHARED) + set_property(TARGET Boost::iostreams APPEND PROPERTY + INTERFACE_LINK_LIBRARIES ZLIB::ZLIB) + endif() else() set(BOOST_J 1 CACHE STRING "max jobs for Boost build") # override w/-DBOOST_J= -- 2.39.5