]> git.saurik.com Git - apt.git/commitdiff
CMake: Handle endian.h locations on other platforms
authorJulian Andres Klode <jak@debian.org>
Mon, 22 Aug 2016 20:54:07 +0000 (22:54 +0200)
committerJulian Andres Klode <jak@debian.org>
Fri, 26 Aug 2016 13:49:14 +0000 (15:49 +0200)
Gbp-Dch: ignore

CMake/config.h.in
CMake/endian.h.in [new file with mode: 0644]
CMakeLists.txt

index e929646fa4324bf645f8aadde923c696d8272681..f32f15b8a49e580e3706e63e91e8241f1fced97f 100644 (file)
 /* Define if we have sys/mount.h */
 #cmakedefine HAVE_MOUNT_H
 
+/* Define if we have sys/endian.h */
+#cmakedefine HAVE_SYS_ENDIAN_H
+
+/* Define if we have machine/endian.h */
+#cmakedefine HAVE_MACHINE_ENDIAN_H
+
 /* Define if we have enabled pthread support */
 #cmakedefine HAVE_PTHREAD
 
diff --git a/CMake/endian.h.in b/CMake/endian.h.in
new file mode 100644 (file)
index 0000000..1d9198c
--- /dev/null
@@ -0,0 +1,9 @@
+#include <config.h>
+
+#ifdef HAVE_MACHINE_ENDIAN_H
+#include <machine/endian.h>
+#endif
+#ifdef HAVE_SYS_ENDIAN_H
+#include <sys/types.h>
+#include <sys/endian.h>
+#endif
index 27d0dd5a358bb53873a0bc4dab873ca8bdbb3532..08e43174037760058274b6c0dbb3478903f8ebe1 100644 (file)
@@ -118,6 +118,18 @@ if (CMAKE_USE_PTHREADS_INIT)
   set(HAVE_PTHREAD 1)
 endif()
 
+CHECK_INCLUDE_FILES(machine/endian.h HAVE_MACHINE_ENDIAN_H)
+CHECK_INCLUDE_FILES(sys/endian.h HAVE_SYS_ENDIAN_H)
+CHECK_INCLUDE_FILES(endian.h HAVE_ENDIAN_H)
+if (NOT HAVE_ENDIAN_H)
+  if (HAVE_MACHINE_ENDIAN_H OR HAVE_SYS_ENDIAN_H)
+    configure_file(CMake/endian.h.in ${PROJECT_BINARY_DIR}/include/endian.h)
+  else()
+    message(FATAL_ERROR "Cannot find endian.h")
+  endif()
+endif()
+
+
 include(CheckTypeSize)
 set(CMAKE_EXTRA_INCLUDE_FILES "signal.h")
 check_type_size("sig_t" SIG_T LANGUAGE "CXX")