| 1 |
# Sets the minimum version of CMake required to build the native |
| 2 |
# library. You should either keep the default value or only pass a |
| 3 |
# value of 3.4.0 or lower. |
| 4 |
|
| 5 |
cmake_minimum_required(VERSION 3.4.1) |
| 6 |
|
| 7 |
# Creates and names a library, sets it as either STATIC |
| 8 |
# or SHARED, and provides the relative paths to its source code. |
| 9 |
# You can define multiple libraries, and CMake builds it for you. |
| 10 |
# Gradle automatically packages shared libraries with your APK. |
| 11 |
|
| 12 |
add_library( # Sets the name of the library. |
| 13 |
native-lib |
| 14 |
|
| 15 |
# Sets the library as a shared library. |
| 16 |
SHARED |
| 17 |
|
| 18 |
# Provides a relative path to your source file(s). |
| 19 |
# Associated headers in the same location as their source |
| 20 |
# file are automatically included. |
| 21 |
src/main/cpp/native-lib.cpp ) |
| 22 |
|
| 23 |
# Searches for a specified prebuilt library and stores the path as a |
| 24 |
# variable. Because system libraries are included in the search path by |
| 25 |
# default, you only need to specify the name of the public NDK library |
| 26 |
# you want to add. CMake verifies that the library exists before |
| 27 |
# completing its build. |
| 28 |
|
| 29 |
find_library( # Sets the name of the path variable. |
| 30 |
log-lib |
| 31 |
|
| 32 |
# Specifies the name of the NDK library that |
| 33 |
# you want CMake to locate. |
| 34 |
log ) |
| 35 |
|
| 36 |
# Specifies libraries CMake should link to your target library. You |
| 37 |
# can link multiple libraries, such as libraries you define in the |
| 38 |
# build script, prebuilt third-party libraries, or system libraries. |
| 39 |
|
| 40 |
target_link_libraries( # Specifies the target library. |
| 41 |
native-lib |
| 42 |
|
| 43 |
# Links the target library to the log library |
| 44 |
# included in the NDK. |
| 45 |
${r"${log-lib}"} ) |