Remove optional dependencies on Boost's dynamic libraries.

Using precompiled Boost libraries can lead to depending on external dynamic libraries.
This commit is contained in:
Tsuda Kageyu
2016-12-09 09:42:29 +09:00
parent 8eda5d5053
commit 250c59f783
5 changed files with 33 additions and 107 deletions

View File

@ -32,7 +32,7 @@ elseif(HAVE_ZLIB_SOURCE)
include_directories(${ZLIB_SOURCE})
endif()
if(HAVE_BOOST_BYTESWAP OR HAVE_BOOST_ATOMIC OR HAVE_BOOST_ZLIB)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIR})
endif()
@ -344,18 +344,10 @@ set(tag_LIB_SRCS
add_library(tag ${tag_LIB_SRCS} ${tag_HDRS})
if(ZLIB_FOUND)
if(HAVE_ZLIB AND NOT HAVE_ZLIB_SOURCE)
target_link_libraries(tag ${ZLIB_LIBRARIES})
endif()
if(HAVE_BOOST_ATOMIC)
target_link_libraries(tag ${Boost_ATOMIC_LIBRARY})
endif()
if(HAVE_BOOST_ZLIB)
target_link_libraries(tag ${Boost_IOSTREAMS_LIBRARY} ${Boost_ZLIB_LIBRARY})
endif()
set_target_properties(tag PROPERTIES
VERSION ${TAGLIB_SOVERSION_MAJOR}.${TAGLIB_SOVERSION_MINOR}.${TAGLIB_SOVERSION_PATCH}
SOVERSION ${TAGLIB_SOVERSION_MAJOR}

View File

@ -34,11 +34,6 @@
# define ATOMIC_INT std::atomic<unsigned int>
# define ATOMIC_INC(x) x.fetch_add(1)
# define ATOMIC_DEC(x) (x.fetch_sub(1) - 1)
#elif defined(HAVE_BOOST_ATOMIC)
# include <boost/atomic.hpp>
# define ATOMIC_INT boost::atomic<unsigned int>
# define ATOMIC_INC(x) x.fetch_add(1)
# define ATOMIC_DEC(x) (x.fetch_sub(1) - 1)
#elif defined(HAVE_GCC_ATOMIC)
# define ATOMIC_INT int
# define ATOMIC_INC(x) __sync_add_and_fetch(&x, 1)

View File

@ -27,23 +27,19 @@
# include <config.h>
#endif
#if defined(HAVE_ZLIB)
#ifdef HAVE_ZLIB
# include <zlib.h>
#elif defined(HAVE_BOOST_ZLIB)
# include <boost/iostreams/filtering_streambuf.hpp>
# include <boost/iostreams/filter/zlib.hpp>
# include <tstring.h>
# include <tdebug.h>
#endif
#include <tstring.h>
#include <tdebug.h>
#include "tzlib.h"
using namespace TagLib;
bool zlib::isAvailable()
{
#if defined(HAVE_ZLIB) || defined(HAVE_BOOST_ZLIB)
#ifdef HAVE_ZLIB
return true;
@ -56,7 +52,7 @@ bool zlib::isAvailable()
ByteVector zlib::decompress(const ByteVector &data)
{
#if defined(HAVE_ZLIB)
#ifdef HAVE_ZLIB
z_stream stream = {};
@ -102,38 +98,6 @@ ByteVector zlib::decompress(const ByteVector &data)
return outData;
#elif defined(HAVE_BOOST_ZLIB)
using namespace boost::iostreams;
struct : public sink
{
ByteVector data;
typedef char char_type;
typedef sink_tag category;
std::streamsize write(char const* s, std::streamsize n)
{
const unsigned int originalSize = data.size();
data.resize(static_cast<unsigned int>(originalSize + n));
::memcpy(data.data() + originalSize, s, static_cast<size_t>(n));
return n;
}
} sink;
try {
zlib_decompressor().write(sink, data.data(), data.size());
}
catch(const zlib_error &) {
debug("zlib::decompress() - Error reading compressed stream.");
return ByteVector();
}
return sink.data;
#else
return ByteVector();