2024-06-26 17:33:02 +02:00
|
|
|
set(LLAMA_VERSION @LLAMA_INSTALL_VERSION@)
|
2023-09-14 19:04:40 +02:00
|
|
|
set(LLAMA_BUILD_COMMIT @LLAMA_BUILD_COMMIT@)
|
|
|
|
set(LLAMA_BUILD_NUMBER @LLAMA_BUILD_NUMBER@)
|
2024-06-26 17:33:02 +02:00
|
|
|
set(LLAMA_SHARED_LIB @BUILD_SHARED_LIBS@)
|
|
|
|
|
|
|
|
set(GGML_ACCELERATE @GGML_ACCELERATE@)
|
2024-07-13 18:12:39 +02:00
|
|
|
set(GGML_VULKAN_CHECK_RESULTS @GGML_VULKAN_CHECK_RESULTS@)
|
|
|
|
set(GGML_VULKAN_DEBUG @GGML_VULKAN_DEBUG@)
|
|
|
|
set(GGML_VULKAN_MEMORY_DEBUG @GGML_VULKAN_MEMORY_DEBUG@)
|
|
|
|
set(GGML_VULKAN_VALIDATE @GGML_VULKAN_VALIDATE@)
|
|
|
|
set(GGML_OPENMP @GGML_OPENMP@)
|
2023-09-14 19:04:40 +02:00
|
|
|
|
|
|
|
@PACKAGE_INIT@
|
|
|
|
|
|
|
|
set_and_check(LLAMA_INCLUDE_DIR "@PACKAGE_LLAMA_INCLUDE_INSTALL_DIR@")
|
2024-06-26 17:33:02 +02:00
|
|
|
set_and_check(LLAMA_LIB_DIR "@PACKAGE_LLAMA_LIB_INSTALL_DIR@")
|
|
|
|
set_and_check(LLAMA_BIN_DIR "@PACKAGE_LLAMA_BIN_INSTALL_DIR@")
|
2023-09-14 19:04:40 +02:00
|
|
|
|
|
|
|
find_package(Threads REQUIRED)
|
2024-06-26 17:33:02 +02:00
|
|
|
|
2024-11-19 17:10:30 +01:00
|
|
|
set(_llama_transient_defines "@GGML_TRANSIENT_DEFINES@")
|
|
|
|
set(_llama_link_deps "")
|
|
|
|
foreach(_ggml_lib ggml ggml-base)
|
|
|
|
string(REPLACE "-" "_" _ggml_lib_var "${_ggml_lib}_LIBRARY")
|
|
|
|
find_library(${_ggml_lib_var} ${_ggml_lib}
|
|
|
|
REQUIRED
|
|
|
|
HINTS ${LLAMA_LIB_DIR}
|
|
|
|
NO_CMAKE_FIND_ROOT_PATH
|
|
|
|
)
|
|
|
|
list(APPEND _llama_link_deps "${${_ggml_lib_var}}")
|
|
|
|
message(STATUS "Found ${${_ggml_lib_var}}")
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
foreach(backend amx blas cann cpu cuda hip kompute metal musa rpc sycl vulkan)
|
|
|
|
string(TOUPPER "GGML_${backend}" backend_id)
|
|
|
|
set(_ggml_lib "ggml-${backend}")
|
|
|
|
string(REPLACE "-" "_" _ggml_lib_var "${_ggml_lib}_LIBRARY")
|
|
|
|
|
|
|
|
find_library(${_ggml_lib_var} ${_ggml_lib}
|
|
|
|
HINTS ${LLAMA_LIB_DIR}
|
|
|
|
NO_CMAKE_FIND_ROOT_PATH
|
|
|
|
)
|
|
|
|
if(${_ggml_lib_var})
|
|
|
|
list(APPEND _llama_link_deps "${${_ggml_lib_var}}")
|
|
|
|
set(${backend_id} ON)
|
|
|
|
message(STATUS "Found backend ${${_ggml_lib_var}}")
|
|
|
|
else()
|
|
|
|
set(${backend_id} OFF)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2024-06-26 17:33:02 +02:00
|
|
|
if (APPLE AND GGML_ACCELERATE)
|
2023-09-14 19:04:40 +02:00
|
|
|
find_library(ACCELERATE_FRAMEWORK Accelerate REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
2024-06-26 17:33:02 +02:00
|
|
|
if (GGML_BLAS)
|
2023-09-14 19:04:40 +02:00
|
|
|
find_package(BLAS REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
2024-06-26 17:33:02 +02:00
|
|
|
if (GGML_CUDA)
|
2023-09-14 19:04:40 +02:00
|
|
|
find_package(CUDAToolkit REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
2024-06-26 17:33:02 +02:00
|
|
|
if (GGML_METAL)
|
2023-09-14 19:04:40 +02:00
|
|
|
find_library(FOUNDATION_LIBRARY Foundation REQUIRED)
|
|
|
|
find_library(METAL_FRAMEWORK Metal REQUIRED)
|
|
|
|
find_library(METALKIT_FRAMEWORK MetalKit REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
2024-07-13 18:12:39 +02:00
|
|
|
if (GGML_VULKAN)
|
|
|
|
find_package(Vulkan REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
2024-11-19 17:10:30 +01:00
|
|
|
if (GGML_HIP)
|
2023-09-14 19:04:40 +02:00
|
|
|
find_package(hip REQUIRED)
|
|
|
|
find_package(hipblas REQUIRED)
|
|
|
|
find_package(rocblas REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
2024-07-13 18:12:39 +02:00
|
|
|
if (GGML_SYCL)
|
|
|
|
find_package(IntelSYCL REQUIRED)
|
|
|
|
find_package(MKL REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (GGML_OPENMP)
|
|
|
|
find_package(OpenMP REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
2023-09-14 19:04:40 +02:00
|
|
|
find_library(llama_LIBRARY llama
|
|
|
|
REQUIRED
|
2024-11-18 16:23:58 +01:00
|
|
|
HINTS ${LLAMA_LIB_DIR}
|
|
|
|
NO_CMAKE_FIND_ROOT_PATH
|
|
|
|
)
|
2023-09-14 19:04:40 +02:00
|
|
|
|
|
|
|
add_library(llama UNKNOWN IMPORTED)
|
|
|
|
set_target_properties(llama
|
|
|
|
PROPERTIES
|
|
|
|
INTERFACE_INCLUDE_DIRECTORIES "${LLAMA_INCLUDE_DIR}"
|
|
|
|
INTERFACE_LINK_LIBRARIES "${_llama_link_deps}"
|
2023-10-02 11:51:49 +02:00
|
|
|
INTERFACE_COMPILE_DEFINITIONS "${_llama_transient_defines}"
|
2023-09-14 19:04:40 +02:00
|
|
|
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
|
|
|
|
IMPORTED_LOCATION "${llama_LIBRARY}"
|
|
|
|
INTERFACE_COMPILE_FEATURES cxx_std_11
|
|
|
|
POSITION_INDEPENDENT_CODE ON )
|
|
|
|
|
|
|
|
check_required_components(Llama)
|