From 55b9c0374c943bd5d7224190bed8d3228dd0d792 Mon Sep 17 00:00:00 2001 From: Stuart Cunningham Date: Thu, 13 Feb 2014 22:59:30 +1100 Subject: [PATCH] Fix cmake detection of build platform endianness Improve comments to indicate actual usage of WORDS_BIGENDIAN where it is tested with #ifdef rather than #if --- 3rdparty/libtiff/CMakeLists.txt | 2 -- 3rdparty/libtiff/tif_config.h.cmakein | 14 +++----------- CMakeLists.txt | 6 ++++++ cmake/templates/cvconfig.h.in | 2 +- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/3rdparty/libtiff/CMakeLists.txt b/3rdparty/libtiff/CMakeLists.txt index 5793021b78..addbb5551c 100644 --- a/3rdparty/libtiff/CMakeLists.txt +++ b/3rdparty/libtiff/CMakeLists.txt @@ -6,7 +6,6 @@ project(${TIFF_LIBRARY}) include(CheckFunctionExists) include(CheckIncludeFile) -include(TestBigEndian) check_include_file(assert.h HAVE_ASSERT_H) check_include_file(fcntl.h HAVE_FCNTL_H) @@ -17,7 +16,6 @@ check_include_file(search.h HAVE_SEARCH_H) check_include_file(string.h HAVE_STRING_H) check_include_file(sys/types.h HAVE_SYS_TYPES_H) check_include_file(unistd.h HAVE_UNISTD_H) -test_big_endian(HOST_BIGENDIAN) if(WIN32 AND NOT HAVE_WINRT) set(USE_WIN32_FILEIO 1) diff --git a/3rdparty/libtiff/tif_config.h.cmakein b/3rdparty/libtiff/tif_config.h.cmakein index 55c6cb26a0..d46761b525 100644 --- a/3rdparty/libtiff/tif_config.h.cmakein +++ b/3rdparty/libtiff/tif_config.h.cmakein @@ -54,7 +54,7 @@ /* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian (Intel) */ -#define HOST_BIGENDIAN @HOST_BIGENDIAN@ +#define HOST_BIGENDIAN @WORDS_BIGENDIAN@ /* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ #define HOST_FILLORDER FILLORDER_LSB2MSB @@ -154,17 +154,9 @@ /* define to use win32 IO system */ #cmakedefine USE_WIN32_FILEIO -/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most +/* Define WORDS_BIGENDIAN if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ -#if defined AC_APPLE_UNIVERSAL_BUILD -# if defined __BIG_ENDIAN__ -# define WORDS_BIGENDIAN 1 -# endif -#else -# ifndef WORDS_BIGENDIAN -/* # undef WORDS_BIGENDIAN */ -# endif -#endif +#cmakedefine WORDS_BIGENDIAN /* Support Deflate compression */ #define ZIP_SUPPORT 1 diff --git a/CMakeLists.txt b/CMakeLists.txt index c6518cfc0e..6489517659 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -444,6 +444,12 @@ endif() include(cmake/OpenCVPCHSupport.cmake) include(cmake/OpenCVModule.cmake) +# ---------------------------------------------------------------------------- +# Detect endianness of build platform +# ---------------------------------------------------------------------------- +include(TestBigEndian) +test_big_endian(WORDS_BIGENDIAN) + # ---------------------------------------------------------------------------- # Detect 3rd-party libraries # ---------------------------------------------------------------------------- diff --git a/cmake/templates/cvconfig.h.in b/cmake/templates/cvconfig.h.in index a6cee63684..d1c9e65d3d 100644 --- a/cmake/templates/cvconfig.h.in +++ b/cmake/templates/cvconfig.h.in @@ -161,6 +161,6 @@ /* Xine video library */ #cmakedefine HAVE_XINE -/* Define to 1 if your processor stores words with the most significant byte +/* Define if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel and VAX). */ #cmakedefine WORDS_BIGENDIAN