CMakeLists.txt 2.2 KB

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