2 # Check if the system is big endian or little endian
4 # VARIABLE - variable to store the result to
7 MACRO(TEST_BIG_ENDIAN VARIABLE)
8 IF("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$")
9 TRY_RUN(${VARIABLE} HAVE_${VARIABLE}
11 ${CMAKE_ROOT}/Modules/TestBigEndian.c
12 OUTPUT_VARIABLE OUTPUT)
13 IF(${VARIABLE} STREQUAL "FAILED_TO_RUN")
14 MESSAGE(SEND_ERROR "TestBigEndian Failed to run with output: ${OUTPUT}")
15 ENDIF(${VARIABLE} STREQUAL "FAILED_TO_RUN")
16 MESSAGE(STATUS "Check if the system is big endian")
18 FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log
19 "Determining the endianes of the system passed. The system is ")
21 FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log
23 MESSAGE(STATUS "Check if the system is big endian - big endian")
25 FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log
27 MESSAGE(STATUS "Check if the system is big endian - little endian")
29 FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log
30 "Test produced following output:\n${OUTPUT}\n\n")
31 ELSE(HAVE_${VARIABLE})
32 FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log
33 "Determining the endianes of the system failed with the following output:\n${OUTPUT}\n\n")
34 MESSAGE("Check if the system is big endian - failed")
35 ENDIF(HAVE_${VARIABLE})
36 ENDIF("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$")
37 ENDMACRO(TEST_BIG_ENDIAN)