CMakeLists.txt 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. cmake_minimum_required(VERSION 3.12)
  2. project("main-cmake-pkg" C CXX)
  3. set(TARGET main-cmake-pkg)
  4. find_package(Llama 0.0.1 REQUIRED)
  5. # Bake common functionality in with target. Because applications
  6. # using the relocatable Llama package should be outside of the
  7. # source tree, main-cmake-pkg pretends the dependencies are built-in.
  8. set(_common_path "${CMAKE_CURRENT_LIST_DIR}/../../common")
  9. add_library(common OBJECT
  10. ${_common_path}/common.h
  11. ${_common_path}/common.cpp
  12. ${_common_path}/console.h
  13. ${_common_path}/console.cpp
  14. ${_common_path}/grammar-parser.h
  15. ${_common_path}/grammar-parser.cpp
  16. )
  17. # WARNING: because build-info.h is auto-generated, it will only
  18. # be available after the user has built the llama.cpp sources.
  19. #
  20. configure_file(${_common_path}/../build-info.h
  21. ${CMAKE_CURRENT_BINARY_DIR}/build-info.h
  22. COPYONLY)
  23. target_include_directories(common PUBLIC ${LLAMA_INCLUDE_DIR}
  24. ${CMAKE_CURRENT_BINARY_DIR})
  25. add_executable(${TARGET} ${CMAKE_CURRENT_LIST_DIR}/../main/main.cpp)
  26. target_include_directories(${TARGET} PRIVATE ${_common_path})
  27. install(TARGETS ${TARGET} RUNTIME)
  28. target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT})
  29. target_compile_features(${TARGET} PRIVATE cxx_std_11)