1b7183c5a1
ggml-metal.metal must be in the same directory as the ollama binary otherwise llama.cpp will not be able to find it and load it. 1. go generate llama/llama_metal.go 2. go build . 3. ./ollama serve
23 lines
908 B
CMake
23 lines
908 B
CMake
cmake_minimum_required(VERSION 3.12)
|
|
project(binding)
|
|
|
|
include(FetchContent)
|
|
|
|
FetchContent_Declare(
|
|
llama_cpp
|
|
GIT_REPOSITORY https://github.com/ggerganov/llama.cpp.git
|
|
GIT_TAG 55dbb91
|
|
)
|
|
|
|
FetchContent_MakeAvailable(llama_cpp)
|
|
|
|
add_library(binding ${CMAKE_CURRENT_SOURCE_DIR}/binding/binding.cpp ${llama_cpp_SOURCE_DIR}/examples/common.cpp)
|
|
target_include_directories(binding PRIVATE ${llama_cpp_SOURCE_DIR}/examples)
|
|
target_link_libraries(binding llama ggml_static)
|
|
|
|
if (LLAMA_METAL)
|
|
configure_file(${llama_cpp_SOURCE_DIR}/ggml-metal.metal ${CMAKE_CURRENT_BINARY_DIR}/../../ggml-metal.metal COPYONLY)
|
|
endif()
|
|
|
|
add_custom_target(copy_libllama ALL COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:llama> ${CMAKE_CURRENT_BINARY_DIR})
|
|
add_custom_target(copy_libggml_static ALL COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:ggml_static> ${CMAKE_CURRENT_BINARY_DIR})
|