Cross-compiling with CMake for Android x86 with API lower than 21 fails
When using CMake options as described on official site: `cmake ../src -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=9 -DCMAKE_ANDROID_ARCH_ABI=x86 -DCMAKE_ANDROID_NDK=/path/to/android-ndk -DCMAKE_ANDROID_STL_TYPE=c++_static` `https://cmake.org/cmake/help/v3.7/manual/cmake-toolchains.7.html#cross-compiling-for-android` and building for Android x86 with API version < 21 and gcc 4.9 on host x64 Ubuntu machine, then we get the following error: ``` /.../boost/1.61.0/build/include/boost/asio/impl/serial_port_base.ipp: In member function 'boost::system::error_code boost::asio::serial_port_base::baud_rate::store(termios&, boost::system::error_code&) const': /.../boost/1.61.0/build/include/boost/asio/impl/serial_port_base.ipp:119:3: error: '::cfsetspeed' has not been declared ::cfsetspeed(&storage, baud); ^ make: *** [all] Error 2 ``` Probably this error occured because `_BSD_SOURCE` is defined in following header: `path_to_ndk/toolchains/x86-4.9/prebuilt/linux-x86_64/lib/gcc/i686-linux-android/4.9/include-fixed/asm/posix_types.h` included instead of needed `path_to_ndk/platforms/android-9/arch-x86/usr/include/asm/posix_types.h` , that's why `_BSD_SOURCE` is defined and it leads to errors when compiling third-party libraries (Boost etc) When using custom toolchain file `https://github.com/taka-no-me/android-cmake/blob/master/android.toolchain.cmake` `_BSD_SOURCE` gets never defined.
issue