Merge f45ba0d0ef into 05fa625eac
This commit is contained in:
commit
f620295fb0
|
|
@ -79,9 +79,12 @@ if (WIN32)
|
||||||
set(CMAKE_SHARED_MODULE_PREFIX "")
|
set(CMAKE_SHARED_MODULE_PREFIX "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(BUILD_SHARED_LIBS "ggml: build shared libraries" ${BUILD_SHARED_LIBS_DEFAULT})
|
option(BUILD_SHARED_LIBS "ggml: build shared libraries" ${BUILD_SHARED_LIBS_DEFAULT})
|
||||||
option(GGML_BACKEND_DL "ggml: build backends as dynamic libraries (requires BUILD_SHARED_LIBS)" OFF)
|
option(GGML_BACKEND_DL "ggml: build backends as dynamic libraries (requires BUILD_SHARED_LIBS)" OFF)
|
||||||
set(GGML_BACKEND_DIR "" CACHE PATH "ggml: directory to load dynamic backends from (requires GGML_BACKEND_DL")
|
set(GGML_BACKEND_DIR "" CACHE PATH "ggml: DEPRECATED: directory to load dynamic backends from (requires GGML_BACKEND_DL")
|
||||||
|
set(GGML_BACKEND_INSTALL_DIR "" CACHE PATH "ggml: directory to install dynamic backends into (requires GGML_BACKEND_DL")
|
||||||
|
set(GGML_BACKEND_ABSOLUTE_SEARCH_DIR "" CACHE PATH "ggml: directory to load dynamic backends from (requires GGML_BACKEND_DL")
|
||||||
|
set(GGML_BACKEND_RELATIVE_TO_EXE_SEARCH_DIR "" CACHE PATH "ggml: directory relative to the executable to load dynamic backends from (requires GGML_BACKEND_DL")
|
||||||
|
|
||||||
#
|
#
|
||||||
# option list
|
# option list
|
||||||
|
|
|
||||||
|
|
@ -232,11 +232,32 @@ set_target_properties(ggml PROPERTIES
|
||||||
)
|
)
|
||||||
|
|
||||||
if (GGML_BACKEND_DIR)
|
if (GGML_BACKEND_DIR)
|
||||||
|
message(WARNING "GGML_BACKEND_DIR is deprecated: use GGML_BACKEND_INSTALL_DIR along with GGML_BACKEND_ABSOLUTE_SEARCH_DIR or GGML_BACKEND_RELATIVE_TO_EXE_SEARCH_DIR instead")
|
||||||
if (NOT GGML_BACKEND_DL)
|
if (NOT GGML_BACKEND_DL)
|
||||||
message(FATAL_ERROR "GGML_BACKEND_DIR requires GGML_BACKEND_DL")
|
message(FATAL_ERROR "GGML_BACKEND_DIR requires GGML_BACKEND_DL")
|
||||||
endif()
|
endif()
|
||||||
|
if (GGML_BACKEND_INSTALL_DIR OR GGML_BACKEND_ABSOLUTE_SEARCH_DIR OR GGML_BACKEND_RELATIVE_TO_EXE_SEARCH_DIR)
|
||||||
|
message(FATAL_ERROR "Cannot use GGML_BACKEND_DIR with GGML_BACKEND_INSTALL_DIR, GGML_BACKEND_ABSOLUTE_SEARCH_DIR, or GGML_BACKEND_RELATIVE_TO_EXE_SEARCH_DIR")
|
||||||
|
endif()
|
||||||
target_compile_definitions(ggml PUBLIC GGML_BACKEND_DIR="${GGML_BACKEND_DIR}")
|
target_compile_definitions(ggml PUBLIC GGML_BACKEND_DIR="${GGML_BACKEND_DIR}")
|
||||||
endif()
|
endif()
|
||||||
|
if (GGML_BACKEND_INSTALL_DIR)
|
||||||
|
if (NOT GGML_BACKEND_DL)
|
||||||
|
message(FATAL_ERROR "GGML_BACKEND_INSTALL_DIR requires GGML_BACKEND_DL")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
if (GGML_BACKEND_ABSOLUTE_SEARCH_DIR)
|
||||||
|
if (NOT GGML_BACKEND_DL)
|
||||||
|
message(FATAL_ERROR "GGML_BACKEND_ABSOLUTE_SEARCH_DIR requires GGML_BACKEND_DL")
|
||||||
|
endif()
|
||||||
|
target_compile_definitions(ggml PUBLIC GGML_BACKEND_ABSOLUTE_SEARCH_DIR="${GGML_BACKEND_ABSOLUTE_SEARCH_DIR}")
|
||||||
|
endif()
|
||||||
|
if (GGML_BACKEND_RELATIVE_TO_EXE_SEARCH_DIR)
|
||||||
|
if (NOT GGML_BACKEND_DL)
|
||||||
|
message(FATAL_ERROR "GGML_BACKEND_RELATIVE_TO_EXE_SEARCH_DIR requires GGML_BACKEND_DL")
|
||||||
|
endif()
|
||||||
|
target_compile_definitions(ggml PUBLIC GGML_BACKEND_RELATIVE_TO_EXE_SEARCH_DIR="${GGML_BACKEND_RELATIVE_TO_EXE_SEARCH_DIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_libraries(ggml PUBLIC ggml-base)
|
target_link_libraries(ggml PUBLIC ggml-base)
|
||||||
|
|
||||||
|
|
@ -252,7 +273,11 @@ function(ggml_add_backend_library backend)
|
||||||
target_compile_definitions(${backend} PRIVATE GGML_BACKEND_DL)
|
target_compile_definitions(${backend} PRIVATE GGML_BACKEND_DL)
|
||||||
add_dependencies(ggml ${backend})
|
add_dependencies(ggml ${backend})
|
||||||
if (GGML_BACKEND_DIR)
|
if (GGML_BACKEND_DIR)
|
||||||
|
# NOTE: GGML_BACKEND_DIR is deprecated, use GGML_BACKEND_INSTALL_DIR along with
|
||||||
|
# GGML_BACKEND_ABSOLUTE_SEARCH_DIR or GGML_BACKEND_RELATIVE_TO_EXE_SEARCH_DIR instead.
|
||||||
install(TARGETS ${backend} LIBRARY DESTINATION ${GGML_BACKEND_DIR})
|
install(TARGETS ${backend} LIBRARY DESTINATION ${GGML_BACKEND_DIR})
|
||||||
|
elseif (GGML_BACKEND_INSTALL_DIR)
|
||||||
|
install(TARGETS ${backend} LIBRARY DESTINATION ${GGML_BACKEND_INSTALL_DIR})
|
||||||
else()
|
else()
|
||||||
install(TARGETS ${backend} LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR})
|
install(TARGETS ${backend} LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -459,11 +459,20 @@ static ggml_backend_reg_t ggml_backend_load_best(const char * name, bool silent,
|
||||||
|
|
||||||
std::vector<fs::path> search_paths;
|
std::vector<fs::path> search_paths;
|
||||||
if (user_search_path == nullptr) {
|
if (user_search_path == nullptr) {
|
||||||
|
const fs::path executable_path = get_executable_path();
|
||||||
|
#ifdef GGML_BACKEND_RELATIVE_TO_EXE_SEARCH_DIR
|
||||||
|
search_paths.push_back(executable_path / fs::u8path(GGML_BACKEND_RELATIVE_TO_EXE_SEARCH_DIR));
|
||||||
|
#endif
|
||||||
#ifdef GGML_BACKEND_DIR
|
#ifdef GGML_BACKEND_DIR
|
||||||
|
// NOTE: GGML_BACKEND_DIR is deprecated, use GGML_BACKEND_ABSOLUTE_SEARCH_DIR or
|
||||||
|
// GGML_BACKEND_RELATIVE_TO_EXE_SEARCH_DIR along with GGML_BACKEND_INSTALL_DIR instead.
|
||||||
search_paths.push_back(fs::u8path(GGML_BACKEND_DIR));
|
search_paths.push_back(fs::u8path(GGML_BACKEND_DIR));
|
||||||
|
#endif
|
||||||
|
#ifdef GGML_BACKEND_ABSOLUTE_SEARCH_DIR
|
||||||
|
search_paths.push_back(fs::u8path(GGML_BACKEND_ABSOLUTE_SEARCH_DIR));
|
||||||
#endif
|
#endif
|
||||||
// default search paths: executable directory, current directory
|
// default search paths: executable directory, current directory
|
||||||
search_paths.push_back(get_executable_path());
|
search_paths.push_back(executable_path);
|
||||||
search_paths.push_back(fs::current_path());
|
search_paths.push_back(fs::current_path());
|
||||||
} else {
|
} else {
|
||||||
search_paths.push_back(fs::u8path(user_search_path));
|
search_paths.push_back(fs::u8path(user_search_path));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue