|
| 1 | + |
| 2 | +# For more information about using CMake with Android Studio, read the |
| 3 | +# documentation: https://d.android.com/studio/projects/add-native-code.html. |
| 4 | +# For more examples on how to use CMake, see https://github.com/android/ndk-samples. |
| 5 | + |
| 6 | +# Sets the minimum CMake version required for this project. |
| 7 | +cmake_minimum_required(VERSION 3.22.1) |
| 8 | + |
| 9 | +# Declares the project name. The project name can be accessed via ${ PROJECT_NAME}, |
| 10 | +# Since this is the top level CMakeLists.txt, the project name is also accessible |
| 11 | +# with ${CMAKE_PROJECT_NAME} (both CMake variables are in-sync within the top level |
| 12 | +# build script scope). |
| 13 | +project("native-lib") |
| 14 | + |
| 15 | +# Creates and names a library, sets it as either STATIC |
| 16 | +# or SHARED, and provides the relative paths to its source code. |
| 17 | +# You can define multiple libraries, and CMake builds them for you. |
| 18 | +# Gradle automatically packages shared libraries with your APK. |
| 19 | +# |
| 20 | +# In this top level CMakeLists.txt, ${CMAKE_PROJECT_NAME} is used to define |
| 21 | +# the target library name; in the sub-module's CMakeLists.txt, ${PROJECT_NAME} |
| 22 | +# is preferred for the same purpose. |
| 23 | +# |
| 24 | +# In order to load a library into your app from Java/Kotlin, you must call |
| 25 | +# System.loadLibrary() and pass the name of the library defined here; |
| 26 | +# for GameActivity/NativeActivity derived applications, the same library name must be |
| 27 | +# used in the AndroidManifest.xml file. |
| 28 | +add_library(${CMAKE_PROJECT_NAME} SHARED |
| 29 | + # List C/C++ source files with relative paths to this CMakeLists.txt. |
| 30 | + native-lib.cpp |
| 31 | + crasher.c |
| 32 | + crasher_2.c |
| 33 | + crasher_3.c |
| 34 | + crasher_4.cpp |
| 35 | + ) |
| 36 | +find_library( # Sets the name of the path variable. |
| 37 | + log-lib |
| 38 | + |
| 39 | + # Specifies the name of the NDK library that |
| 40 | + # you want CMake to locate. |
| 41 | + log) |
| 42 | + |
| 43 | + |
| 44 | +# Specifies libraries CMake should link to your target library. You |
| 45 | +# can link libraries from various origins, such as libraries defined in this |
| 46 | +# build script, prebuilt third-party libraries, or Android system libraries. |
| 47 | +target_link_libraries(${CMAKE_PROJECT_NAME} |
| 48 | + # List libraries link to the target library |
| 49 | + android |
| 50 | + log |
| 51 | + ${log-lib} |
| 52 | + ) |
0 commit comments