CMakeLists.txt 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # For more information about using CMake with Android Studio, read the
  2. # documentation: https://d.android.com/studio/projects/add-native-code.html.
  3. # For more examples on how to use CMake, see https://github.com/android/ndk-samples.
  4. # Sets the minimum CMake version required for this project.
  5. cmake_minimum_required(VERSION 3.22.1)
  6. # Declares the project name. The project name can be accessed via ${ PROJECT_NAME},
  7. # Since this is the top level CMakeLists.txt, the project name is also accessible
  8. # with ${CMAKE_PROJECT_NAME} (both CMake variables are in-sync within the top level
  9. # build script scope).
  10. project("llama-android")
  11. include(FetchContent)
  12. FetchContent_Declare(
  13. llama
  14. GIT_REPOSITORY https://github.com/ggerganov/llama.cpp
  15. GIT_TAG master
  16. )
  17. # Also provides "common"
  18. FetchContent_MakeAvailable(llama)
  19. # Creates and names a library, sets it as either STATIC
  20. # or SHARED, and provides the relative paths to its source code.
  21. # You can define multiple libraries, and CMake builds them for you.
  22. # Gradle automatically packages shared libraries with your APK.
  23. #
  24. # In this top level CMakeLists.txt, ${CMAKE_PROJECT_NAME} is used to define
  25. # the target library name; in the sub-module's CMakeLists.txt, ${PROJECT_NAME}
  26. # is preferred for the same purpose.
  27. #
  28. # In order to load a library into your app from Java/Kotlin, you must call
  29. # System.loadLibrary() and pass the name of the library defined here;
  30. # for GameActivity/NativeActivity derived applications, the same library name must be
  31. # used in the AndroidManifest.xml file.
  32. add_library(${CMAKE_PROJECT_NAME} SHARED
  33. # List C/C++ source files with relative paths to this CMakeLists.txt.
  34. llama-android.cpp)
  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.
  38. target_link_libraries(${CMAKE_PROJECT_NAME}
  39. # List libraries link to the target library
  40. llama
  41. common
  42. android
  43. log)