]> granicus.if.org Git - taglib/commitdiff
Skip unnecessary CMake tests
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Mon, 22 Apr 2013 23:38:43 +0000 (08:38 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Mon, 22 Apr 2013 23:47:48 +0000 (08:47 +0900)
ConfigureChecks.cmake
config-taglib.h.cmake
taglib/toolkit/tbytevector.cpp

index 11db70d85dec44b81cb63445d6c204e5104459ac..67b99d881177b52574f0d0f620b99c4c0e0de0ad 100644 (file)
@@ -11,176 +11,194 @@ include(TestBigEndian)
 
 test_big_endian(TAGLIB_BIG_ENDIAN)
 
-if(NOT ${TAGLIB_BIG_ENDIAN})
-set(TAGLIB_LITTLE_ENDIAN 1)
+if(NOT TAGLIB_BIG_ENDIAN)
+  set(TAGLIB_LITTLE_ENDIAN 1)
 endif()
 
 # Determine the size of integral types.
 
-check_type_size("short"     SIZEOF_SHORT)
-check_type_size("int"       SIZEOF_INT)
+check_type_size("short"   SIZEOF_SHORT)
+check_type_size("int"     SIZEOF_INT)
 check_type_size("long long" SIZEOF_LONGLONG)
 check_type_size("wchar_t"   SIZEOF_WCHAR_T)
 
 # Determine if your compiler supports std::wstring.
 
 check_cxx_source_compiles("
-       #include <string>
-       int main() { 
-               std::wstring x(L\"ABC\");
-               return 0; 
-       }
+  #include <string>
+  int main() { 
+    std::wstring x(L\"ABC\");
+    return 0; 
+  }
 " HAVE_STD_WSTRING)
 
 # Determine which kind of atomic operations your compiler supports.
 
 check_cxx_source_compiles("
-       #include <atomic>
-       int main() { 
-               std::atomic<unsigned int> x;
-               x.fetch_add(1);
-               x.fetch_sub(1);
-               return 0; 
-       }
+  #include <atomic>
+  int main() { 
+    std::atomic<unsigned int> x;
+    x.fetch_add(1);
+    x.fetch_sub(1);
+    return 0; 
+  }
 " 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)
-
-check_cxx_source_compiles("
-       int main() { 
-               volatile int x;
-               __sync_add_and_fetch(&x, 1);
-               int y = __sync_sub_and_fetch(&x, 1);
-               return 0; 
-       }
-" HAVE_GCC_ATOMIC)
-
-check_cxx_source_compiles("
-       #include <libkern/OSAtomic.h>
-       int main() { 
-               volatile int32_t x;
-               OSAtomicIncrement32Barrier(&x);
-               int32_t y = OSAtomicDecrement32Barrier(&x);
-               return 0; 
-       }
-" HAVE_MAC_ATOMIC)
-
-check_cxx_source_compiles("
-       #include <windows.h>
-       int main() { 
-               volatile LONG x;
-               InterlockedIncrement(&x);
-               LONG y = InterlockedDecrement(&x);
-               return 0; 
-       }
-" HAVE_WIN_ATOMIC)
-
-check_cxx_source_compiles("
-       #include <ia64intrin.h>
-       int main() { 
-               volatile int x;
-               __sync_add_and_fetch(&x, 1);
-               int y = __sync_sub_and_fetch(&x, 1);
-               return 0; 
-       }
-" HAVE_IA64_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)
+
+  if(NOT HAVE_BOOST_ATOMIC)
+    check_cxx_source_compiles("
+      int main() { 
+        volatile int x;
+        __sync_add_and_fetch(&x, 1);
+        int y = __sync_sub_and_fetch(&x, 1);
+        return 0; 
+      }
+    " HAVE_GCC_ATOMIC)
+
+    if(NOT HAVE_GCC_ATOMIC)
+      check_cxx_source_compiles("
+        #include <libkern/OSAtomic.h>
+        int main() { 
+          volatile int32_t x;
+          OSAtomicIncrement32Barrier(&x);
+          int32_t y = OSAtomicDecrement32Barrier(&x);
+          return 0; 
+        }
+      " HAVE_MAC_ATOMIC)
+
+      if(NOT HAVE_MAC_ATOMIC)
+        check_cxx_source_compiles("
+          #include <windows.h>
+          int main() { 
+            volatile LONG x;
+            InterlockedIncrement(&x);
+            LONG y = InterlockedDecrement(&x);
+            return 0; 
+          }
+        " HAVE_WIN_ATOMIC)
+
+        if(NOT HAVE_WIN_ATOMIC)
+          check_cxx_source_compiles("
+            #include <ia64intrin.h>
+            int main() { 
+              volatile int x;
+              __sync_add_and_fetch(&x, 1);
+              int y = __sync_sub_and_fetch(&x, 1);
+              return 0; 
+            }
+          " HAVE_IA64_ATOMIC)
+        endif()
+      endif()
+    endif()
+  endif()
+endif()
 
 # Determine which kind of byte swap functions your compiler supports.
 
-# Some of them can be missing depends on the GCC version.
+# GCC's __builtin_bswap* should be checked individually 
+# because some of them can be missing depends on the GCC version.
 check_cxx_source_compiles("
-       int main() {
-               __builtin_bswap16(0);
-               return 0; 
-       }
+  int main() {
+    __builtin_bswap16(0);
+    return 0; 
+  }
 " HAVE_GCC_BYTESWAP_16)
 
 check_cxx_source_compiles("
-       int main() {
-               __builtin_bswap32(0);
-               return 0; 
-       }
+  int main() {
+    __builtin_bswap32(0);
+    return 0; 
+  }
 " HAVE_GCC_BYTESWAP_32)
 
 check_cxx_source_compiles("
-       int main() {
-               __builtin_bswap64(0);
-               return 0; 
-       }
+  int main() {
+    __builtin_bswap64(0);
+    return 0; 
+  }
 " HAVE_GCC_BYTESWAP_64)
 
-check_cxx_source_compiles("
-       #include <stdlib.h>
-       int main() {
-               _byteswap_ushort(0);
-               _byteswap_ulong(0);
-               _byteswap_uint64(0);
-               return 0; 
-       }
-" HAVE_MSC_BYTESWAP)
-
-check_cxx_source_compiles("
-       #include <byteswap.h>
-       int main() {
-               __bswap_16(0);
-               __bswap_32(0);
-               __bswap_64(0);
-               return 0; 
-       }
-" HAVE_GLIBC_BYTESWAP)
-
-check_cxx_source_compiles("
-       #include <libkern/OSByteOrder.h>
-       int main() {
-               OSSwapInt16(0);
-               OSSwapInt32(0);
-               OSSwapInt64(0);
-               return 0; 
-       }
-" HAVE_MAC_BYTESWAP)
-
-check_cxx_source_compiles("
-       #include <sys/endian.h>
-       int main() {
-               swap16(0);
-               swap32(0);
-               swap64(0);
-               return 0; 
-       }
-" HAVE_OPENBSD_BYTESWAP)
+if(NOT HAVE_GCC_BYTESWAP_16 OR NOT HAVE_GCC_BYTESWAP_32 OR NOT HAVE_GCC_BYTESWAP_64)
+  check_cxx_source_compiles("
+    #include <byteswap.h>
+    int main() {
+      __bswap_16(0);
+      __bswap_32(0);
+      __bswap_64(0);
+      return 0; 
+    }
+  " HAVE_GLIBC_BYTESWAP)
+
+  if(NOT HAVE_GLIBC_BYTESWAP)
+    check_cxx_source_compiles("
+      #include <stdlib.h>
+      int main() {
+        _byteswap_ushort(0);
+        _byteswap_ulong(0);
+        _byteswap_uint64(0);
+        return 0; 
+      }
+    " HAVE_MSC_BYTESWAP)
+
+    if(NOT HAVE_MSC_BYTESWAP)
+      check_cxx_source_compiles("
+        #include <libkern/OSByteOrder.h>
+        int main() {
+          OSSwapInt16(0);
+          OSSwapInt32(0);
+          OSSwapInt64(0);
+          return 0; 
+        }
+      " 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()
 
 # Determine whether your compiler supports codecvt.
 
 check_cxx_source_compiles("
-       #include <codecvt>
-       int main() { 
-               std::codecvt_utf8_utf16<wchar_t> x; 
-               return 0; 
-       }
+  #include <codecvt>
+  int main() { 
+    std::codecvt_utf8_utf16<wchar_t> x; 
+    return 0; 
+  }
 " HAVE_STD_CODECVT)
 
 # Check for libz using the cmake supplied FindZLIB.cmake
 
 find_package(ZLIB)
 if(ZLIB_FOUND)
-       set(HAVE_ZLIB 1)
+  set(HAVE_ZLIB 1)
 else()
-       set(HAVE_ZLIB 0)
+  set(HAVE_ZLIB 0)
 endif()
 
 
 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
 find_package(CppUnit)
 if(NOT CppUnit_FOUND AND BUILD_TESTS)
-       message(STATUS "CppUnit not found, disabling tests.")
-       set(BUILD_TESTS OFF)
+  message(STATUS "CppUnit not found, disabling tests.")
+  set(BUILD_TESTS OFF)
 endif()
-
index bb25bb868c010837b873f3a5ef6816ffc14af897..aee25a792106d1ab469a89fb26bb68698d6c9629 100644 (file)
@@ -25,8 +25,8 @@
 #cmakedefine   HAVE_GCC_BYTESWAP_16 1
 #cmakedefine   HAVE_GCC_BYTESWAP_32 1
 #cmakedefine   HAVE_GCC_BYTESWAP_64 1
-#cmakedefine   HAVE_MSC_BYTESWAP 1
 #cmakedefine   HAVE_GLIBC_BYTESWAP 1
+#cmakedefine   HAVE_MSC_BYTESWAP 1
 #cmakedefine   HAVE_MAC_BYTESWAP 1
 #cmakedefine   HAVE_OPENBSD_BYTESWAP 1
 
@@ -41,4 +41,3 @@
 #cmakedefine   WITH_MP4 1
 
 #cmakedefine TESTS_DIR "@TESTS_DIR@"
-
index a4b12672ae4ee36eaa48434f7d271e5852946b08..06f38b6eebdf655cb5d61a589adc3877ab740028 100644 (file)
@@ -222,14 +222,14 @@ ulonglong byteSwap<ulonglong>(ulonglong x)
 
 #else
 
-  return (x & 0xff00000000000000ull) >> 56) 
-    | (x & 0x00ff000000000000ull) >> 40)     
-    | (x & 0x0000ff0000000000ull) >> 24)     
-    | (x & 0x000000ff00000000ull) >> 8)      
-    | (x & 0x00000000ff000000ull) << 8)      
-    | (x & 0x0000000000ff0000ull) << 24)     
-    | (x & 0x000000000000ff00ull) << 40)     
-    | (x & 0x00000000000000ffull) << 56);
+  return ((x & 0xff00000000000000ull) >> 56)
+    | ((x & 0x00ff000000000000ull) >> 40)
+    | ((x & 0x0000ff0000000000ull) >> 24)
+    | ((x & 0x000000ff00000000ull) >> 8)
+    | ((x & 0x00000000ff000000ull) << 8)
+    | ((x & 0x0000000000ff0000ull) << 24)
+    | ((x & 0x000000000000ff00ull) << 40)
+    | ((x & 0x00000000000000ffull) << 56);
 
 #endif
 }