# Sets the minimum version of CMake required to build the native
# library.
cmake_minimum_required(VERSION 3.4.1)

# Specifies a library name, specifies whether the library is STATIC or
# SHARED, and provides relative paths to the source code. You can
# define multiple libraries by adding multiple add_library() commands,
# and CMake builds them for you. When you build your app, Gradle
# automatically packages shared libraries with your APK.
add_library( # Specifies the name of the library.
             fapm

             # Sets the library as a shared library.
             SHARED

             # Provides a relative path to your source file(s).
             jank_monitor.cpp
             jank_ffi.cpp
             logging.cpp
             elf_info_parser.c
             stack_helper.cpp
             include/dart_api_dl.c
        )

find_library( # Defines the name of the path variable that stores the
              # location of the NDK library.
              log-lib

              # Specifies the name of the NDK library that
              # you want CMake to locate.
              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.
                       fapm

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

target_link_options(fapm PRIVATE
  "-Wl,-z,max-page-size=16384"
  "-Wl,-z,common-page-size=4096"
)