ENH: for universal binaries return the endianess based on the processor

Alex
This commit is contained in:
Alexander Neundorf 2007-08-13 11:04:19 -04:00
parent 54f0a2f0a0
commit 263bb4e172
1 changed files with 18 additions and 8 deletions

View File

@ -57,6 +57,19 @@ MACRO(TEST_BIG_ENDIAN VARIABLE)
FILE(STRINGS "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestEndianess.bin"
CMAKE_TEST_ENDIANESS_STRINGS_BE LIMIT_COUNT 1 REGEX "THIS IS BIG ENDIAN")
# on mac, if there are universal binaries built both will be true
# return the result depending on the machine on which cmake runs
IF(CMAKE_TEST_ENDIANESS_STRINGS_BE AND CMAKE_TEST_ENDIANESS_STRINGS_LE)
IF(CMAKE_SYSTEM_PROCESSOR MATCHES powerpc)
SET(CMAKE_TEST_ENDIANESS_STRINGS_BE TRUE)
SET(CMAKE_TEST_ENDIANESS_STRINGS_LE FALSE)
ELSE(CMAKE_SYSTEM_PROCESSOR MATCHES powerpc)
SET(CMAKE_TEST_ENDIANESS_STRINGS_BE FALSE)
SET(CMAKE_TEST_ENDIANESS_STRINGS_LE TRUE)
ENDIF(CMAKE_SYSTEM_PROCESSOR MATCHES powerpc)
MESSAGE(STATUS "TEST_BIG_ENDIAN found different results, consider setting CMAKE_OSX_ARCHITECTURES or CMAKE_TRY_COMPILE_OSX_ARCHITECTURES to one or no architecture !")
ENDIF(CMAKE_TEST_ENDIANESS_STRINGS_BE AND CMAKE_TEST_ENDIANESS_STRINGS_LE)
IF(CMAKE_TEST_ENDIANESS_STRINGS_LE)
SET(${VARIABLE} 0 CACHE INTERNAL "Result of TEST_BIG_ENDIAN" FORCE)
MESSAGE(STATUS "Check if the system is big endian - little endian")
@ -67,9 +80,6 @@ MACRO(TEST_BIG_ENDIAN VARIABLE)
MESSAGE(STATUS "Check if the system is big endian - big endian")
ENDIF(CMAKE_TEST_ENDIANESS_STRINGS_BE)
IF(CMAKE_TEST_ENDIANESS_STRINGS_BE AND CMAKE_TEST_ENDIANESS_STRINGS_LE)
MESSAGE(STATUS "TEST_BIG_ENDIAN found different results, consider setting CMAKE_OSX_ARCHITECTURES or CMAKE_TRY_COMPILE_OSX_ARCHITECTURES to one or no architecture !")
ENDIF(CMAKE_TEST_ENDIANESS_STRINGS_BE AND CMAKE_TEST_ENDIANESS_STRINGS_LE)
IF(NOT CMAKE_TEST_ENDIANESS_STRINGS_BE AND NOT CMAKE_TEST_ENDIANESS_STRINGS_LE)
MESSAGE(SEND_ERROR "TEST_BIG_ENDIAN found no result!")
ENDIF(NOT CMAKE_TEST_ENDIANESS_STRINGS_BE AND NOT CMAKE_TEST_ENDIANESS_STRINGS_LE)