From 30b7f44ead04b57db14f035f27762c419ee818f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Mangano?= Date: Sat, 14 Nov 2020 20:27:08 +0100 Subject: [PATCH] Include endian.h or sys/endian.h depending on the platform --- CMakeLists.txt | 5 +++++ src/config.h.in | 3 +++ src/opus.cc | 8 ++++++++ 3 files changed, 16 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b6e81fd..03f5a31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,11 @@ link_directories(${OGG_LIBRARY_DIRS}) include(FindIconv) +# We need endian.h on Linux, and sys/endian.h on BSD. +include(CheckIncludeFileCXX) +check_include_file_cxx(endian.h HAVE_ENDIAN_H) +check_include_file_cxx(sys/endian.h HAVE_SYS_ENDIAN_H) + configure_file(src/config.h.in config.h @ONLY) include_directories(BEFORE src "${CMAKE_BINARY_DIR}" ${OGG_INCLUDE_DIRS} ${Iconv_INCLUDE_DIRS}) diff --git a/src/config.h.in b/src/config.h.in index a447c65..7699db8 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -1,2 +1,5 @@ #cmakedefine PROJECT_NAME "@PROJECT_NAME@" #cmakedefine PROJECT_VERSION "@PROJECT_VERSION@" + +#cmakedefine HAVE_ENDIAN_H @HAVE_ENDIAN_H@ +#cmakedefine HAVE_SYS_ENDIAN_H @HAVE_SYS_ENDIAN_H@ diff --git a/src/opus.cc b/src/opus.cc index 34dd6d3..ed8e49b 100644 --- a/src/opus.cc +++ b/src/opus.cc @@ -25,6 +25,14 @@ #include +#ifdef HAVE_ENDIAN_H +# include +#endif + +#ifdef HAVE_SYS_ENDIAN_H +# include +#endif + #ifdef __APPLE__ #include #define htole32(x) OSSwapHostToLittleInt32(x)