Make building llava optional
This commit is contained in:
parent
74f1949206
commit
e3941d9c67
2 changed files with 28 additions and 25 deletions
|
@ -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,28 +45,30 @@ if (LLAMA_BUILD)
|
|||
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
|
||||
)
|
||||
|
||||
# Building llava
|
||||
add_subdirectory(vendor/llama.cpp/examples/llava)
|
||||
set_target_properties(llava_shared PROPERTIES OUTPUT_NAME "llava")
|
||||
# Set CUDA_ARCHITECTURES to OFF on windows
|
||||
if (WIN32)
|
||||
set_target_properties(llava_shared PROPERTIES CUDA_ARCHITECTURES OFF)
|
||||
if (LLAVA_BUILD)
|
||||
# Building llava
|
||||
add_subdirectory(vendor/llama.cpp/examples/llava)
|
||||
set_target_properties(llava_shared PROPERTIES OUTPUT_NAME "llava")
|
||||
# Set CUDA_ARCHITECTURES to OFF on windows
|
||||
if (WIN32)
|
||||
set_target_properties(llava_shared PROPERTIES CUDA_ARCHITECTURES OFF)
|
||||
endif()
|
||||
install(
|
||||
TARGETS llava_shared
|
||||
LIBRARY DESTINATION ${SKBUILD_PLATLIB_DIR}/llama_cpp
|
||||
RUNTIME DESTINATION ${SKBUILD_PLATLIB_DIR}/llama_cpp
|
||||
ARCHIVE DESTINATION ${SKBUILD_PLATLIB_DIR}/llama_cpp
|
||||
FRAMEWORK DESTINATION ${SKBUILD_PLATLIB_DIR}/llama_cpp
|
||||
RESOURCE DESTINATION ${SKBUILD_PLATLIB_DIR}/llama_cpp
|
||||
)
|
||||
# Temporary fix for https://github.com/scikit-build/scikit-build-core/issues/374
|
||||
install(
|
||||
TARGETS llava_shared
|
||||
LIBRARY DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
|
||||
RUNTIME DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
|
||||
ARCHIVE DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
|
||||
FRAMEWORK DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
|
||||
RESOURCE DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
|
||||
)
|
||||
endif()
|
||||
install(
|
||||
TARGETS llava_shared
|
||||
LIBRARY DESTINATION ${SKBUILD_PLATLIB_DIR}/llama_cpp
|
||||
RUNTIME DESTINATION ${SKBUILD_PLATLIB_DIR}/llama_cpp
|
||||
ARCHIVE DESTINATION ${SKBUILD_PLATLIB_DIR}/llama_cpp
|
||||
FRAMEWORK DESTINATION ${SKBUILD_PLATLIB_DIR}/llama_cpp
|
||||
RESOURCE DESTINATION ${SKBUILD_PLATLIB_DIR}/llama_cpp
|
||||
)
|
||||
# Temporary fix for https://github.com/scikit-build/scikit-build-core/issues/374
|
||||
install(
|
||||
TARGETS llava_shared
|
||||
LIBRARY DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
|
||||
RUNTIME DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
|
||||
ARCHIVE DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
|
||||
FRAMEWORK DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
|
||||
RESOURCE DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -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()]
|
||||
|
|
Loading…
Reference in a new issue