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)