1
0
mirror of git://f0xx.org/android_cast synced 2026-07-29 06:39:09 +03:00
Files
android_cast/ndk/CMakeLists.txt
Anton Afanasyeu f7e200fa94 snap
2026-05-18 15:55:02 +02:00

50 lines
1.8 KiB
CMake

cmake_minimum_required(VERSION 3.22.1)
project(androidcast_codecs C)
set(CMAKE_C_STANDARD 11)
set(THIRD_PARTY_ROOT ${CMAKE_SOURCE_DIR}/../third-party)
set(NATIVE_LIBS_ROOT ${CMAKE_SOURCE_DIR}/../build/native)
set(NDK_BRIDGE ${CMAKE_SOURCE_DIR})
add_library(androidcast_codecs SHARED
${NDK_BRIDGE}/jni/androidcast_codecs.c
${NDK_BRIDGE}/jni/libvpx_bridge.c
${NDK_BRIDGE}/jni/opus_bridge.c
${NDK_BRIDGE}/jni/speex_bridge.c
)
target_include_directories(androidcast_codecs PRIVATE
${NDK_BRIDGE}/jni
)
# Per-ABI libvpx.a from scripts/build-native-codecs.sh (do not link arm64 into armeabi-v7a).
set(LIBVPX_LIB "")
if(ANDROID_ABI)
set(LIBVPX_PER_ABI "${NATIVE_LIBS_ROOT}/${ANDROID_ABI}/libvpx.a")
if(EXISTS "${LIBVPX_PER_ABI}")
set(LIBVPX_LIB "${LIBVPX_PER_ABI}")
endif()
endif()
if(NOT LIBVPX_LIB AND DEFINED ENV{ANDROIDCAST_LIBVPX_LIB})
string(FIND "$ENV{ANDROIDCAST_LIBVPX_LIB}" "${ANDROID_ABI}" _abi_match)
if(_abi_match GREATER -1 AND EXISTS "$ENV{ANDROIDCAST_LIBVPX_LIB}")
set(LIBVPX_LIB "$ENV{ANDROIDCAST_LIBVPX_LIB}")
endif()
endif()
if(LIBVPX_LIB)
message(STATUS "Linking libvpx for ${ANDROID_ABI}: ${LIBVPX_LIB}")
target_compile_definitions(androidcast_codecs PRIVATE ANDROIDCAST_HAVE_LIBVPX=1)
target_link_libraries(androidcast_codecs "${LIBVPX_LIB}")
if(EXISTS "${THIRD_PARTY_ROOT}/libvpx")
target_include_directories(androidcast_codecs PRIVATE "${THIRD_PARTY_ROOT}/libvpx")
target_include_directories(androidcast_codecs PRIVATE "${THIRD_PARTY_ROOT}/libvpx/vpx")
endif()
else()
message(STATUS "No libvpx.a for ${ANDROID_ABI} — VPx JNI probe off (build with scripts/build-native-codecs.sh ${ANDROID_ABI})")
endif()
find_library(log-lib log)
target_link_libraries(androidcast_codecs ${log-lib})