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. 7cmake_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). 13project("benchmarkNative") 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. 28add_library(${CMAKE_PROJECT_NAME} SHARED 29 # List C/C++ source files with relative paths to this CMakeLists.txt. 30 androidx_benchmark_BlackHole.cpp 31 androidx_benchmark_CpuCounter.cpp 32 Profiler.cpp 33) 34 35# Specifies libraries CMake should link to your target library. You 36# can link libraries from various origins, such as libraries defined in this 37# build script, prebuilt third-party libraries, or Android system libraries. 38target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC log) 39target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE dl) 40target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC android) 41target_link_options(${CMAKE_PROJECT_NAME} PRIVATE "-Wl,-z,max-page-size=16384") 42