|
| 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("hips") |
| 14 | + |
| 15 | +# Include CMake's FetchContent module |
| 16 | +include(FetchContent) |
| 17 | + |
| 18 | +# Declare Git repo to fetch llama.cpp library from (has to be called "llama") |
| 19 | +FetchContent_Declare( |
| 20 | + llama |
| 21 | + GIT_REPOSITORY https://github.com/ggerganov/llama.cpp |
| 22 | + GIT_TAG master |
| 23 | +) |
| 24 | + |
| 25 | +# Fetch llama.cpp (also provides "common") |
| 26 | +FetchContent_MakeAvailable(llama) |
| 27 | + |
| 28 | +# Creates and names a library, sets it as either STATIC |
| 29 | +# or SHARED, and provides the relative paths to its source code. |
| 30 | +# You can define multiple libraries, and CMake builds them for you. |
| 31 | +# Gradle automatically packages shared libraries with your APK. |
| 32 | +# |
| 33 | +# In this top level CMakeLists.txt, ${CMAKE_PROJECT_NAME} is used to define |
| 34 | +# the target library name; in the sub-module's CMakeLists.txt, ${PROJECT_NAME} |
| 35 | +# is preferred for the same purpose. |
| 36 | +# |
| 37 | +# In order to load a library into your app from Java/Kotlin, you must call |
| 38 | +# System.loadLibrary() and pass the name of the library defined here; |
| 39 | +# for GameActivity/NativeActivity derived applications, the same library name must be |
| 40 | +# used in the AndroidManifest.xml file. |
| 41 | +add_library(${CMAKE_PROJECT_NAME} SHARED |
| 42 | + # List C/C++ source files with relative paths to this CMakeLists.txt. |
| 43 | + hips.cpp) |
| 44 | + |
| 45 | +# Specifies libraries CMake should link to your target library. You |
| 46 | +# can link libraries from various origins, such as libraries defined in this |
| 47 | +# build script, prebuilt third-party libraries, or Android system libraries. |
| 48 | +target_link_libraries(${CMAKE_PROJECT_NAME} |
| 49 | + # List libraries link to the target library |
| 50 | + android |
| 51 | + log |
| 52 | + llama |
| 53 | + common |
| 54 | +) |
0 commit comments