blob: 2d1853cc26cf159fe34443c28c9328f30302cf5a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# - Define macro to determine endian type
# Check if the system is big endian or little endian
# TEST_BIG_ENDIAN(VARIABLE)
# VARIABLE - variable to store the result to
#
MACRO(TEST_BIG_ENDIAN VARIABLE)
SET(CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS 1)
IF(NOT DEFINED ${VARIABLE})
IF("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$")
TRY_RUN(${VARIABLE} HAVE_${VARIABLE}
${CMAKE_BINARY_DIR}
${CMAKE_ROOT}/Modules/TestBigEndian.c
COMPILE_OUTPUT_VARIABLE OUTPUT)
IF("${VARIABLE}" STREQUAL "FAILED_TO_RUN")
MESSAGE(SEND_ERROR "TestBigEndian Failed to run with output: ${OUTPUT}")
ENDIF("${VARIABLE}" STREQUAL "FAILED_TO_RUN")
MESSAGE(STATUS "Check if the system is big endian")
IF(HAVE_${VARIABLE})
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining the endianes of the system passed. The system is ")
IF(${VARIABLE})
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"big endian")
MESSAGE(STATUS "Check if the system is big endian - big endian")
ELSE(${VARIABLE})
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"little endian")
MESSAGE(STATUS "Check if the system is big endian - little endian")
ENDIF(${VARIABLE})
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Test produced following output:\n${OUTPUT}\n\n")
ELSE(HAVE_${VARIABLE})
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"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}$")
ENDIF(NOT DEFINED ${VARIABLE})
SET(CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS)
ENDMACRO(TEST_BIG_ENDIAN)
|