2005-12-14 21:51:08 +03:00
|
|
|
# - Define macro to determine endian type
|
2002-10-01 23:56:18 +04:00
|
|
|
# Check if the system is big endian or little endian
|
2005-12-14 21:51:08 +03:00
|
|
|
# TEST_BIG_ENDIAN(VARIABLE)
|
|
|
|
# VARIABLE - variable to store the result to
|
2002-10-01 23:56:18 +04:00
|
|
|
#
|
|
|
|
|
|
|
|
MACRO(TEST_BIG_ENDIAN VARIABLE)
|
2007-05-24 16:33:05 +04:00
|
|
|
SET(CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS 1)
|
|
|
|
IF(NOT DEFINED ${VARIABLE})
|
2003-08-08 19:59:07 +04:00
|
|
|
IF("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$")
|
|
|
|
TRY_RUN(${VARIABLE} HAVE_${VARIABLE}
|
|
|
|
${CMAKE_BINARY_DIR}
|
|
|
|
${CMAKE_ROOT}/Modules/TestBigEndian.c
|
|
|
|
OUTPUT_VARIABLE OUTPUT)
|
2005-06-20 21:10:09 +04:00
|
|
|
IF("${VARIABLE}" STREQUAL "FAILED_TO_RUN")
|
2005-02-10 07:00:16 +03:00
|
|
|
MESSAGE(SEND_ERROR "TestBigEndian Failed to run with output: ${OUTPUT}")
|
2005-06-20 21:10:09 +04:00
|
|
|
ENDIF("${VARIABLE}" STREQUAL "FAILED_TO_RUN")
|
2003-08-08 19:59:07 +04:00
|
|
|
MESSAGE(STATUS "Check if the system is big endian")
|
|
|
|
IF(HAVE_${VARIABLE})
|
2006-06-14 20:28:32 +04:00
|
|
|
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
2003-08-08 19:59:07 +04:00
|
|
|
"Determining the endianes of the system passed. The system is ")
|
|
|
|
IF(${VARIABLE})
|
2006-06-14 20:28:32 +04:00
|
|
|
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
2003-08-08 19:59:07 +04:00
|
|
|
"big endian")
|
|
|
|
MESSAGE(STATUS "Check if the system is big endian - big endian")
|
|
|
|
ELSE(${VARIABLE})
|
2006-06-14 20:28:32 +04:00
|
|
|
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
2003-08-08 19:59:07 +04:00
|
|
|
"little endian")
|
|
|
|
MESSAGE(STATUS "Check if the system is big endian - little endian")
|
|
|
|
ENDIF(${VARIABLE})
|
2006-06-14 20:28:32 +04:00
|
|
|
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
2003-08-08 19:59:07 +04:00
|
|
|
"Test produced following output:\n${OUTPUT}\n\n")
|
|
|
|
ELSE(HAVE_${VARIABLE})
|
2006-06-14 20:28:32 +04:00
|
|
|
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
2003-08-08 19:59:07 +04:00
|
|
|
"Determining the endianes of the system failed with the following output:\n${OUTPUT}\n\n")
|
|
|
|
MESSAGE("Check if the system is big endian - failed")
|
|
|
|
ENDIF(HAVE_${VARIABLE})
|
|
|
|
ENDIF("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$")
|
2007-05-24 16:33:05 +04:00
|
|
|
ENDIF(NOT DEFINED ${VARIABLE})
|
|
|
|
SET(CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS)
|
2002-10-01 23:56:18 +04:00
|
|
|
ENDMACRO(TEST_BIG_ENDIAN)
|