aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt18
1 files changed, 18 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1dca028c..f859a7d0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -207,6 +207,24 @@ if (NOT WIN32 AND NOT CYGWIN)
endif ()
endif ()
+# Detect endianness -- this only handles little and big endian.
+# PDP users, sorry, but you're out of luck.'
+if (DEFINED CMAKE_LANG_C_BYTE_ORDER)
+ if (CMAKE_LANG_BYTE_ORDER EQUAL BIG_ENDIAN)
+ add_definitions(-DNNG_BIG_ENDIAN=1)
+ else()
+ add_definitions(-DNNG_LITTLE_ENDIAN=1)
+ endif()
+else()
+ include(TestBigEndian)
+ test_big_endian(NNG_BIG_ENDIAN)
+ if (NNG_BIG_ENDIAN)
+ add_definitions(-DNNG_BIG_EDNDIAN=1)
+ else()
+ add_definitions(-DNNG_LITTLE_ENDIAN=1)
+ endif()
+endif()
+
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
add_definitions(-DNNG_PLATFORM_POSIX)
add_definitions(-DNNG_PLATFORM_LINUX)