croissanne / portaudio_opensles

android opensles hostapi for portaudio
Other
48 stars 16 forks source link

CMake support for OpenSLES #3

Closed jwinarske closed 6 years ago

jwinarske commented 6 years ago

Hi there,

This PR adds CMake support for using OpenSLES. Beyond these changes, I build for Android using a shell script as listed below. Pthread is included in another system library, hence the hot patch for Android:

git checkout CMakeLists.txt
sed -i 's/-lpthread//g' CMakeLists.txt
sed -i 's/pthread//g' CMakeLists.txt
[ ! -d build ] && mkdir build
cd build
rm -rf *
PATH=$TOOLCHAIN_PATH:$PATH cmake \
  -DANDROID_PLATFORM=$PLATFORM \
  -DANDROID_ABI=$ARCH_ABI \
  -DCMAKE_INSTALL_PREFIX:PATH=$OUTPUT \
  -DCMAKE_TOOLCHAIN_FILE=$NDK/build/cmake/android.toolchain.cmake \
  -DCMAKE_BUILD_TYPE=$BUILD_TYPE \
  -DOPENSLES_INCLUDE_DIR="$SYSROOT/usr/include" \
  -DOPENSLES_LIBRARY="$SYSROOT/usr/$LIB_ARCH/libOpenSLES.so" \
  -DPA_ENABLE_DEBUG_OUTPUT=ON \
  -DPA_BUILD_EXAMPLES=ON \
  -DPA_BUILD_TESTS=ON \
  ..
PATH=$TOOLCHAIN_PATH:$PATH make install -j${CPU_COUNT}
croissanne commented 6 years ago

Awesome! Thanks for this.

It seems that starting cmake 3.7 there is the ANDROID variable (https://cmake.org/cmake/help/v3.7/manual/cmake-variables.7.html#variables-that-describe-the-system). Could a version check prevent the pthread hotpatch for cmake>=3.7 by not adding pthread to the PA_PKGCONFIG_LDFLAGS and PA_LIBRARY_DEPENDENCIES variables?