From dfb25dd982b90403643c39b20232da5ee1283579 Mon Sep 17 00:00:00 2001 From: Andy Cedilnik Date: Tue, 1 Oct 2002 15:56:18 -0400 Subject: Add test for big endian --- Modules/TestBigEndian.c | 10 ++++++++++ Modules/TestBigEndian.cmake | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 Modules/TestBigEndian.c create mode 100644 Modules/TestBigEndian.cmake diff --git a/Modules/TestBigEndian.c b/Modules/TestBigEndian.c new file mode 100644 index 0000000..377d1b1 --- /dev/null +++ b/Modules/TestBigEndian.c @@ -0,0 +1,10 @@ +int main () { + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long l; + char c[sizeof (long)]; + } u; + u.l = 1; + exit (u.c[sizeof (long) - 1] == 1); +} diff --git a/Modules/TestBigEndian.cmake b/Modules/TestBigEndian.cmake new file mode 100644 index 0000000..c729a82 --- /dev/null +++ b/Modules/TestBigEndian.cmake @@ -0,0 +1,16 @@ +# +# Check if the system is big endian or little endian +# +# VARIABLE - variable to store the result to +# + +MACRO(TEST_BIG_ENDIAN VARIABLE) + TRY_RUN(${VARIABLE} HAVE_${VARIABLE} + ${PROJECT_BINARY_DIR} + ${CMAKE_ROOT}/Modules/TestBigEndian.c + OUTPUT_VARIABLE OUTPUT) + IF(NOT HAVE_${VARIABLE}) + WRITE_FILE(${PROJECT_BINARY_DIR}/CMakeError.log + "Determining the endianes of the system failed with the following output:\n${OUTPUT}\n") + ENDIF(NOT HAVE_${VARIABLE}) +ENDMACRO(TEST_BIG_ENDIAN) -- cgit v0.12