# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.4.1)

set( Visage_LIBS ${PROJECT_SOURCE_DIR}/../../../../lib/${ANDROID_ABI} )
set( Visage_HEADERS ${PROJECT_SOURCE_DIR}/../../../../include)

include_directories( ${Visage_HEADERS} )
set(ANDROID_STL "c++_shared")

add_library( libomp SHARED IMPORTED )
add_library( tfplugin SHARED IMPORTED )
add_library( VisageVision SHARED IMPORTED )

set_target_properties( libomp PROPERTIES IMPORTED_LOCATION ${Visage_LIBS}/libomp.so )
set_target_properties( tfplugin PROPERTIES IMPORTED_LOCATION ${Visage_LIBS}/libTFPlugin.so )
set_target_properties( VisageVision PROPERTIES IMPORTED_LOCATION ${Visage_LIBS}/libVisageVision.so )

add_library( VisageAnalyser SHARED IMPORTED )

set_target_properties( VisageAnalyser PROPERTIES
                        IMPORTED_LOCATION ${Visage_LIBS}/libVisageAnalyser.so )

set( Wrapper_SOURCE src/main/cpp/AndroidWrapper.cpp
                    src/main/cpp/AndroidStreamCapture.cpp
                    src/main/cpp/VisageRendering.cpp
                    src/main/cpp/AndroidImageCapture.cpp
                    src/main/cpp/AndroidCapture.cpp )

add_library( VisageWrapper SHARED ${Wrapper_SOURCE} )

target_link_libraries( VisageWrapper libomp tfplugin VisageVision VisageAnalyser "-lGLESv1_CM -llog -ldl -Wl,--gc-sections" )