OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I686LINUX / util / I686LINUX / share / CMake / Modules / TestBigEndian.cmake
1 #
2 # Check if the system is big endian or little endian
3 #
4 # VARIABLE - variable to store the result to
5 #
6
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     MESSAGE(STATUS "Check if the system is big endian")
14     IF(HAVE_${VARIABLE})
15       FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log 
16         "Determining the endianes of the system passed. The system is ")
17       IF(${VARIABLE})
18         FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log 
19           "big endian")
20         MESSAGE(STATUS "Check if the system is big endian - big endian")
21       ELSE(${VARIABLE})
22         FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log 
23           "little endian")
24         MESSAGE(STATUS "Check if the system is big endian - little endian")
25       ENDIF(${VARIABLE})
26       FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log
27         "Test produced following output:\n${OUTPUT}\n\n")
28     ELSE(HAVE_${VARIABLE})
29       FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log 
30         "Determining the endianes of the system failed with the following output:\n${OUTPUT}\n\n")
31       MESSAGE("Check if the system is big endian - failed")
32     ENDIF(HAVE_${VARIABLE})
33   ENDIF("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$")
34 ENDMACRO(TEST_BIG_ENDIAN)