1# libgav1JNI requires modern CMake.
2cmake_minimum_required(VERSION 3.7.1 FATAL_ERROR)
3
4# libgav1JNI requires C++11.
5set(CMAKE_CXX_STANDARD 11)
6
7project(libgav1JNI C CXX)
8
9# Devices using armeabi-v7a are not required to support
10# Neon which is why Neon is disabled by default for
11# armeabi-v7a build. This flag enables it.
12if(${ANDROID_ABI} MATCHES "armeabi-v7a")
13    add_compile_options("-mfpu=neon")
14    add_compile_options("-marm")
15    add_compile_options("-fPIC")
16endif()
17
18string(TOLOWER "${CMAKE_BUILD_TYPE}" build_type)
19if(build_type MATCHES "^rel")
20    add_compile_options("-O2")
21endif()
22
23set(libgav1_jni_root "${CMAKE_CURRENT_SOURCE_DIR}")
24set(libgav1_jni_build "${CMAKE_BINARY_DIR}")
25set(libgav1_jni_output_directory
26    ${libgav1_jni_root}/../libs/${ANDROID_ABI}/)
27
28set(libgav1_root "${libgav1_jni_root}/libgav1")
29set(libgav1_build "${libgav1_jni_build}/libgav1")
30
31set(cpu_features_root "${libgav1_jni_root}/cpu_features")
32set(cpu_features_build "${libgav1_jni_build}/cpu_features")
33
34# Build cpu_features library.
35add_subdirectory("${cpu_features_root}"
36                 "${cpu_features_build}"
37                 EXCLUDE_FROM_ALL)
38
39# Build libgav1.
40add_subdirectory("${libgav1_root}"
41                 "${libgav1_build}"
42                 EXCLUDE_FROM_ALL)
43
44# Build libgav1JNI.
45add_library(gav1JNI
46            SHARED
47            gav1_jni.cc)
48
49# Locate NDK log library.
50find_library(android_log_lib log)
51
52# Link libgav1JNI against used libraries.
53target_link_libraries(gav1JNI
54                      PRIVATE android
55                      PRIVATE cpu_features
56                      PRIVATE libgav1_static
57                      PRIVATE ${android_log_lib})
58
59# Specify output directory for libgav1JNI.
60set_target_properties(gav1JNI PROPERTIES
61                      LIBRARY_OUTPUT_DIRECTORY
62                      ${libgav1_jni_output_directory})
63