# Sets the minimum version of CMake required to build the native
# library. You should either keep the default value or only pass a
# value of 3.4.0 or lower.

cmake_minimum_required(VERSION 3.4.1)

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds it for you.
# Gradle automatically packages shared libraries with your APK.

add_library( # Sets the name of the library.
             native-lib

             # Sets the library as a shared library.
             SHARED

             # Provides a relative path to your source file(s).
             # Associated headers in the same location as their source
             # file are automatically included.
             ../../DecodeJP2ToBBB.cpp
             ../../DecodeJP2ToJPG.cpp
             ../../DecodeJP2ToMemory.cpp
             ../../DecodeMrSIDBandSelection.cpp
             ../../DecodeMrSIDLidar.cpp
             ../../DecodeMrSIDToMemory.cpp
             ../../DecodeMrSIDToRaw.cpp
             ../../DecodeMrSIDToTIFF.cpp
             ../../DecodeNITFToBBB.cpp
             ../../DerivedImageFilter.cpp
             ../../DerivedImageReader.cpp
             ../../DerivedImageWriter.cpp
             ../../DerivedStream.cpp
             ../../ErrorHandling.cpp
             ../../GeoScene.cpp
             ../../ImageInfo.cpp
             ../../InterruptDelegate.cpp
             ../../MetadataDump.cpp
             ../../Mosaic.cpp
             ../../Pipeline.cpp
             ../../ProgressDelegate.cpp
             ../../SceneBuffer.cpp
             ../../support.cpp
             ../../UserTest.cpp
             ../../UsingCInterface.c
             ../../UsingCStream.c
             ../../UsingStreams.cpp
              src/main/cpp/native-lib.cpp )

# Specifies a path to native header files.
include_directories( ../../../../include/
                     ../../ )

add_library( ltidsdk
             SHARED
             IMPORTED )

set_target_properties( # Specifies the target library.
                       ltidsdk

                       # Specifies the parameter you want to define.
                       PROPERTIES IMPORTED_LOCATION

                       # Provides the path to the library you want to import.
                       ${CMAKE_SOURCE_DIR}/../../../../lib/${ANDROID_ABI}/libltidsdk.so )

# Searches for a specified prebuilt library and stores the path as a
# variable. Because system libraries are included in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.

find_library( log-lib log )

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in the
# build script, prebuilt third-party libraries, or system libraries.

target_link_libraries( # Specifies the target library.
                       native-lib
                       ltidsdk

                       # Links the target library to the log library
                       # included in the NDK.
                       ${log-lib}
                      )
