Make building llava optional

This commit is contained in:
Andrei Betlen 2023-11-28 04:55:21 -05:00
parent 74f1949206
commit e3941d9c67
2 changed files with 28 additions and 25 deletions

View file

@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.21)
project(llama_cpp)
option(LLAMA_BUILD "Build llama.cpp shared library and install alongside python package" ON)
option(LLAVA_BUILD "Build llava shared library and install alongside python package" ON)
if (LLAMA_BUILD)
set(BUILD_SHARED_LIBS "On")
@ -44,6 +45,7 @@ if (LLAMA_BUILD)
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
)
if (LLAVA_BUILD)
# Building llava
add_subdirectory(vendor/llama.cpp/examples/llava)
set_target_properties(llava_shared PROPERTIES OUTPUT_NAME "llava")
@ -69,3 +71,4 @@ if (LLAMA_BUILD)
RESOURCE DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
)
endif()
endif()

View file

@ -48,8 +48,8 @@ def _load_shared_library(lib_base_name: str):
else:
raise RuntimeError("Unsupported platform")
if "LLAMA_CPP_LIB" in os.environ:
lib_base_name = os.environ["LLAMA_CPP_LIB"]
if "LLAVA_CPP_LIB" in os.environ:
lib_base_name = os.environ["LLAVA_CPP_LIB"]
_lib = pathlib.Path(lib_base_name)
_base_path = _lib.parent.resolve()
_lib_paths = [_lib.resolve()]