diff options
author | Alexander Neundorf <neundorf@kde.org> | 2007-08-13 15:04:19 (GMT) |
---|---|---|
committer | Alexander Neundorf <neundorf@kde.org> | 2007-08-13 15:04:19 (GMT) |
commit | 263bb4e172d58a4e8ce55f147bc46bf50dd7fde1 (patch) | |
tree | 094594362fd165208a865144bb381ddd0bfe4190 /Modules | |
parent | 54f0a2f0a0c744610569921da05c07ffbda85d5a (diff) | |
download | CMake-263bb4e172d58a4e8ce55f147bc46bf50dd7fde1.zip CMake-263bb4e172d58a4e8ce55f147bc46bf50dd7fde1.tar.gz CMake-263bb4e172d58a4e8ce55f147bc46bf50dd7fde1.tar.bz2 |
ENH: for universal binaries return the endianess based on the processor
Alex
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/TestBigEndian.cmake | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/Modules/TestBigEndian.cmake b/Modules/TestBigEndian.cmake index 9d5cd72..ffc3a0c 100644 --- a/Modules/TestBigEndian.cmake +++ b/Modules/TestBigEndian.cmake @@ -42,7 +42,7 @@ MACRO(TEST_BIG_ENDIAN VARIABLE) FILE(READ "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/TestEndianess.c" TEST_ENDIANESS_FILE_CONTENT) - + TRY_COMPILE(HAVE_${VARIABLE} "${CMAKE_BINARY_DIR}" "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/TestEndianess.c" @@ -53,23 +53,33 @@ MACRO(TEST_BIG_ENDIAN VARIABLE) FILE(STRINGS "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestEndianess.bin" CMAKE_TEST_ENDIANESS_STRINGS_LE LIMIT_COUNT 1 REGEX "THIS IS LITTLE ENDIAN") - + 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") ENDIF(CMAKE_TEST_ENDIANESS_STRINGS_LE) - + IF(CMAKE_TEST_ENDIANESS_STRINGS_BE) SET(${VARIABLE} 1 CACHE INTERNAL "Result of TEST_BIG_ENDIAN" FORCE) 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) |