]> granicus.if.org Git - taglib/commitdiff
Find Boost properly.
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Sat, 13 Feb 2016 06:38:35 +0000 (15:38 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Sat, 13 Feb 2016 16:53:02 +0000 (01:53 +0900)
check_cxx_source_compiles() depends on the Visual Studio settings.

ConfigureChecks.cmake
taglib/CMakeLists.txt

index a9f9f17a3a510f1f7c38077b5a59d0f83c6669b3..0e6eb628b3242df970998a31315886e1692494a6 100644 (file)
@@ -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 <boost/atomic.hpp>
-    int main() {
-      boost::atomic<unsigned int> 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 <boost/endian/conversion.hpp>
-  int main() {
-    boost::endian::endian_reverse(static_cast<uint16_t>(1));
-    boost::endian::endian_reverse(static_cast<uint32_t>(1));
-    boost::endian::endian_reverse(static_cast<uint64_t>(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("
index 5a047bf1da50f5427038dc57123c2052ba3e20d7..8e67d7094e7c5ccb8618256e4475ceb31a4c6389 100644 (file)
@@ -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}