Fix endianness with CMake.

Original patch from C. Neidahl.

Change-Id: I734d7cb33c3da5abb8d4faf074277dba53b37147
This commit is contained in:
Vincent Rabaud
2025-09-29 14:33:56 +02:00
parent 158b533d3e
commit 0e5f4ee3de
2 changed files with 11 additions and 9 deletions

View File

@@ -149,6 +149,16 @@ if(WIN32 AND BUILD_SHARED_LIBS)
add_definitions(-DWEBP_DLL)
endif()
# Compatibility with autoconf configure script's way of setting this
if(CMAKE_C_BYTE_ORDER STREQUAL "BIG_ENDIAN")
set(WORDS_BIGENDIAN TRUE)
elseif(CMAKE_C_BYTE_ORDER STREQUAL "LITTLE_ENDIAN")
set(WORDS_BIGENDIAN FALSE)
else()
set(WORDS_BIGENDIAN FALSE)
message(WARNING "Endianness could not be determined.")
endif()
# pkg-config variables used by *.pc.in.
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix "\${prefix}")

View File

@@ -108,12 +108,4 @@
/* Define WORDS_BIGENDIAN to 1 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 1