CMakeLists.txt 908 Bytes
Newer Older
Michael Yang's avatar
Michael Yang committed
1
2
3
cmake_minimum_required(VERSION 3.12)
project(binding)

Jeffrey Morgan's avatar
Jeffrey Morgan committed
4
5
6
7
8
include(FetchContent)

FetchContent_Declare(
    llama_cpp
    GIT_REPOSITORY https://github.com/ggerganov/llama.cpp.git
Jeffrey Morgan's avatar
Jeffrey Morgan committed
9
    GIT_TAG        55dbb91
Jeffrey Morgan's avatar
Jeffrey Morgan committed
10
11
12
13
)

FetchContent_MakeAvailable(llama_cpp)

Jeffrey Morgan's avatar
Jeffrey Morgan committed
14
add_library(binding ${CMAKE_CURRENT_SOURCE_DIR}/binding/binding.cpp ${llama_cpp_SOURCE_DIR}/examples/common.cpp)
Jeffrey Morgan's avatar
Jeffrey Morgan committed
15
16
target_include_directories(binding PRIVATE ${llama_cpp_SOURCE_DIR}/examples)
target_link_libraries(binding llama ggml_static)
Jeffrey Morgan's avatar
Jeffrey Morgan committed
17

Michael Yang's avatar
Michael Yang committed
18
19
20
21
22
23
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})