From b10ec8cc7b6b9d181cccacee6b4c1c4c5bdbd510 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 22 Aug 2016 22:54:07 +0200 Subject: CMake: Handle endian.h locations on other platforms Gbp-Dch: ignore --- CMake/config.h.in | 6 ++++++ CMake/endian.h.in | 9 +++++++++ CMakeLists.txt | 12 ++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 CMake/endian.h.in diff --git a/CMake/config.h.in b/CMake/config.h.in index e929646fa..f32f15b8a 100644 --- a/CMake/config.h.in +++ b/CMake/config.h.in @@ -25,6 +25,12 @@ /* 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 index 000000000..1d9198c24 --- /dev/null +++ b/CMake/endian.h.in @@ -0,0 +1,9 @@ +#include + +#ifdef HAVE_MACHINE_ENDIAN_H +#include +#endif +#ifdef HAVE_SYS_ENDIAN_H +#include +#include +#endif diff --git a/CMakeLists.txt b/CMakeLists.txt index 27d0dd5a3..08e431740 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") -- cgit v1.2.3