]> granicus.if.org Git - taglib/commitdiff
Enable Boost Endian library again.
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Sun, 14 Feb 2016 16:36:17 +0000 (01:36 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Sun, 14 Feb 2016 16:36:17 +0000 (01:36 +0900)
It should be detected properly now.

ConfigureChecks.cmake
config.h.cmake
taglib/CMakeLists.txt
taglib/toolkit/tutils.h

index aef792948688ca79393887555ba4b35cbc04fcc8..6f3c82ec65df7d674004b51778aba0fbcd74d537 100644 (file)
@@ -34,6 +34,13 @@ if(NOT ${SIZEOF_DOUBLE} EQUAL 8)
   message(FATAL_ERROR "TagLib requires that double is 64-bit wide.")
 endif()
 
+# Enable check_cxx_source_compiles() to work with Boost "header-only" libraries.
+
+find_package(Boost)
+if(Boost_FOUND)
+  set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${Boost_INCLUDE_DIRS}")
+endif()
+
 # Determine which kind of atomic operations your compiler supports.
 
 check_cxx_source_compiles("
@@ -103,57 +110,69 @@ endif()
 # Determine which kind of byte swap functions your compiler supports.
 
 check_cxx_source_compiles("
+  #include <boost/endian/conversion.hpp>
   int main() {
-    __builtin_bswap16(0);
-    __builtin_bswap32(0);
-    __builtin_bswap64(0);
+    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_GCC_BYTESWAP)
+" HAVE_BOOST_BYTESWAP)
 
-if(NOT HAVE_GCC_BYTESWAP)
+if(NOT HAVE_BOOST_BYTESWAP)
   check_cxx_source_compiles("
-    #include <byteswap.h>
     int main() {
-      __bswap_16(0);
-      __bswap_32(0);
-      __bswap_64(0);
+      __builtin_bswap16(0);
+      __builtin_bswap32(0);
+      __builtin_bswap64(0);
       return 0;
     }
-  " HAVE_GLIBC_BYTESWAP)
+  " HAVE_GCC_BYTESWAP)
 
-  if(NOT HAVE_GLIBC_BYTESWAP)
+  if(NOT HAVE_GCC_BYTESWAP)
     check_cxx_source_compiles("
-      #include <stdlib.h>
+      #include <byteswap.h>
       int main() {
-        _byteswap_ushort(0);
-        _byteswap_ulong(0);
-        _byteswap_uint64(0);
+        __bswap_16(0);
+        __bswap_32(0);
+        __bswap_64(0);
         return 0;
       }
-    " HAVE_MSC_BYTESWAP)
+    " HAVE_GLIBC_BYTESWAP)
 
-    if(NOT HAVE_MSC_BYTESWAP)
+    if(NOT HAVE_GLIBC_BYTESWAP)
       check_cxx_source_compiles("
-        #include <libkern/OSByteOrder.h>
+        #include <stdlib.h>
         int main() {
-          OSSwapInt16(0);
-          OSSwapInt32(0);
-          OSSwapInt64(0);
+          _byteswap_ushort(0);
+          _byteswap_ulong(0);
+          _byteswap_uint64(0);
           return 0;
         }
-      " HAVE_MAC_BYTESWAP)
+      " HAVE_MSC_BYTESWAP)
 
-      if(NOT HAVE_MAC_BYTESWAP)
+      if(NOT HAVE_MSC_BYTESWAP)
         check_cxx_source_compiles("
-          #include <sys/endian.h>
+          #include <libkern/OSByteOrder.h>
           int main() {
-            swap16(0);
-            swap32(0);
-            swap64(0);
+            OSSwapInt16(0);
+            OSSwapInt32(0);
+            OSSwapInt64(0);
             return 0;
           }
-        " HAVE_OPENBSD_BYTESWAP)
+        " HAVE_MAC_BYTESWAP)
+
+        if(NOT HAVE_MAC_BYTESWAP)
+          check_cxx_source_compiles("
+            #include <sys/endian.h>
+            int main() {
+              swap16(0);
+              swap32(0);
+              swap64(0);
+              return 0;
+            }
+          " HAVE_OPENBSD_BYTESWAP)
+        endif()
       endif()
     endif()
   endif()
index cfaa8eace21b03312f83a408dc622fc6d179957a..7ac724108470f6f9aa80552da4a76a588c133569 100644 (file)
@@ -1,6 +1,7 @@
 /* config.h. Generated by cmake from config.h.cmake */
 
 /* Defined if your compiler supports some byte swap functions */
+#cmakedefine   HAVE_BOOST_BYTESWAP 1
 #cmakedefine   HAVE_GCC_BYTESWAP 1
 #cmakedefine   HAVE_GLIBC_BYTESWAP 1
 #cmakedefine   HAVE_MSC_BYTESWAP 1
index cc2b7611df53b1020e7d940a4304870fdd53d6b0..c30929fc97967730e3b84e208e67d5e745af8ae1 100644 (file)
@@ -32,7 +32,7 @@ elseif(HAVE_ZLIB_SOURCE)
   include_directories(${ZLIB_SOURCE})
 endif()
 
-if(HAVE_BOOST_ATOMIC)
+if(HAVE_BOOST_BYTESWAP OR HAVE_BOOST_ATOMIC)
   include_directories(${Boost_INCLUDE_DIR})
 endif()
 
index 69eccec23b2882914b4964285030408b8f6c3752..bacbc2dd79aa78804e551784f1b30375f44c06c8 100644 (file)
@@ -34,7 +34,9 @@
 # include <config.h>
 #endif
 
-#if defined(HAVE_MSC_BYTESWAP)
+#if defined(HAVE_BOOST_BYTESWAP)
+# include <boost/endian/conversion.hpp>
+#elif defined(HAVE_MSC_BYTESWAP)
 # include <stdlib.h>
 #elif defined(HAVE_GLIBC_BYTESWAP)
 # include <byteswap.h>
@@ -59,7 +61,11 @@ namespace TagLib
      */
     inline unsigned short byteSwap(unsigned short x)
     {
-#if defined(HAVE_GCC_BYTESWAP)
+#if defined(HAVE_BOOST_BYTESWAP)
+
+      return boost::endian::endian_reverse(x);
+
+#elif defined(HAVE_GCC_BYTESWAP)
 
       return __builtin_bswap16(x);
 
@@ -91,7 +97,11 @@ namespace TagLib
      */
     inline unsigned int byteSwap(unsigned int x)
     {
-#if defined(HAVE_GCC_BYTESWAP)
+#if defined(HAVE_BOOST_BYTESWAP)
+
+      return boost::endian::endian_reverse(x);
+
+#elif defined(HAVE_GCC_BYTESWAP)
 
       return __builtin_bswap32(x);
 
@@ -126,7 +136,11 @@ namespace TagLib
      */
     inline unsigned long long byteSwap(unsigned long long x)
     {
-#if defined(HAVE_GCC_BYTESWAP)
+#if defined(HAVE_BOOST_BYTESWAP)
+
+      return boost::endian::endian_reverse(x);
+
+#elif defined(HAVE_GCC_BYTESWAP)
 
       return __builtin_bswap64(x);