[CMake] Use ExternalProject_Add to include Opus in Android

Yusuf Kaba kaba1729.ai at gmail.com
Sat Dec 2 03:12:06 EST 2017


I have an Android project that uses NDK. I will like to include the opus
<https://opus-codec.org/downloads/> source code in the native code. I have
tried using the ExternalProject_Add property of CMake but my native code
still cannot import headers from the Opus library and fails to build.

Some of my native classes are dependent on the Opus source code. I was able
to include the Opus source using by adding a Makefile to the source and
including that in the Android.mk file so I want to do something similar
with CMake. Is it possible to include local sources in CMake and specify an
Android.mk file that will be used to build such sources.

Best,

NB: Here's my current ExternalProject_Add definition:

ExternalProject_Add(project_opus
  URL https://archive.mozilla.org/pub/opus/opus-1.2.1.tar.gz
  CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR>
  BUILD_COMMAND make
  INSTALL_COMMAND make install)
ExternalProject_Get_Property(project_opus install_dir)
include_directories(${install_dir}/include)

add_library(opus SHARED IMPORTED)
add_dependencies(opus project_opus)

target_link_libraries( # Specifies the target library.
                       native-lib

                       # Links the target library to the log library
                       # included in the NDK.
                       ${log-lib} opus oboe OpenSLES)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20171202/3c9eede5/attachment-0001.html>


More information about the CMake mailing list