From ab2267f9aae8643a6ff1a8809dc745cd97d2cb48 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Sat, 13 Feb 2016 15:38:35 +0900 Subject: [PATCH] Find Boost properly. check_cxx_source_compiles() depends on the Visual Studio settings. --- ConfigureChecks.cmake | 32 ++++++++++++++------------------ taglib/CMakeLists.txt | 8 ++++++++ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index a9f9f17a..0e6eb628 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -34,6 +34,13 @@ if(NOT ${SIZEOF_DOUBLE} EQUAL 8) message(FATAL_ERROR "TagLib requires that double is 64-bit wide.") endif() +# Determine whether Boost "header-only" libraries are installed. + +find_package(Boost) +if(Boost_FOUND) + set(Boost_VERSION "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") +endif() + # Determine which kind of atomic operations your compiler supports. check_cxx_source_compiles(" @@ -47,15 +54,10 @@ check_cxx_source_compiles(" " HAVE_STD_ATOMIC) if(NOT HAVE_STD_ATOMIC) - check_cxx_source_compiles(" - #include - int main() { - boost::atomic x(1); - x.fetch_add(1); - x.fetch_sub(1); - return 0; - } - " HAVE_BOOST_ATOMIC) + find_package(Boost COMPONENTS atomic) + if(Boost_ATOMIC_FOUND) + set(HAVE_BOOST_ATOMIC 1) + endif() if(NOT HAVE_BOOST_ATOMIC) check_cxx_source_compiles(" @@ -107,15 +109,9 @@ endif() # Determine which kind of byte swap functions your compiler supports. -check_cxx_source_compiles(" - #include - int main() { - boost::endian::endian_reverse(static_cast(1)); - boost::endian::endian_reverse(static_cast(1)); - boost::endian::endian_reverse(static_cast(1)); - return 0; - } -" HAVE_BOOST_BYTESWAP) +if(Boost_FOUND AND NOT (Boost_VERSION VERSION_LESS "1.58.0")) + set(HAVE_BOOST_BYTESWAP 1) +endif() if(NOT HAVE_BOOST_BYTESWAP) check_cxx_source_compiles(" diff --git a/taglib/CMakeLists.txt b/taglib/CMakeLists.txt index 5a047bf1..8e67d709 100644 --- a/taglib/CMakeLists.txt +++ b/taglib/CMakeLists.txt @@ -32,6 +32,10 @@ elseif(HAVE_ZLIB_SOURCE) include_directories(${ZLIB_SOURCE}) endif() +if(HAVE_BOOST_ATOMIC OR HAVE_BOOST_BYTESWAP) + include_directories(${Boost_INCLUDE_DIR}) +endif() + set(tag_HDRS tag.h fileref.h @@ -343,6 +347,10 @@ if(ZLIB_FOUND) target_link_libraries(tag ${ZLIB_LIBRARIES}) endif() +if(HAVE_BOOST_ATOMIC) + target_link_libraries(tag ${Boost_ATOMIC_LIBRARY}) +endif() + set_target_properties(tag PROPERTIES VERSION ${TAGLIB_SOVERSION_MAJOR}.${TAGLIB_SOVERSION_MINOR}.${TAGLIB_SOVERSION_PATCH} SOVERSION ${TAGLIB_SOVERSION_MAJOR}