STYLE: Nightly Version update
[cmake.git] / Modules / TestBigEndian.cmake
blobf121bdff5c3114e0327574597a77017d0993098a
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}
10       ${CMAKE_BINARY_DIR}
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")
17     IF(HAVE_${VARIABLE})
18       FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log 
19         "Determining the endianes of the system passed. The system is ")
20       IF(${VARIABLE})
21         FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log 
22           "big endian")
23         MESSAGE(STATUS "Check if the system is big endian - big endian")
24       ELSE(${VARIABLE})
25         FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log 
26           "little endian")
27         MESSAGE(STATUS "Check if the system is big endian - little endian")
28       ENDIF(${VARIABLE})
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)