Skip to content

Commit c364253

Browse files
committed
cmake: Don't require all backends installed with GGML_BACKEND_DL=ON
For example, distributions may ship both HIP and CUDA backends, but it's unlikely that a user will have both installed at the same time.
1 parent 599a919 commit c364253

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

ggml/cmake/ggml-config.cmake.in

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,22 @@ if(NOT TARGET ggml::ggml)
129129
string(REPLACE "-" "_" _ggml_backend_pfx "${_ggml_backend}")
130130
string(TOUPPER "${_ggml_backend_pfx}" _ggml_backend_pfx)
131131

132-
find_library(${_ggml_backend_pfx}_LIBRARY ${_ggml_backend}
133-
REQUIRED
134-
HINTS ${GGML_BACKEND_DIR} ${GGML_LIB_DIR}
135-
NO_CMAKE_FIND_ROOT_PATH)
132+
if (GGML_BACKEND_DL)
133+
# On systems with dynamically loaded backends, it's OK if not all are installed
134+
find_library(${_ggml_backend_pfx}_LIBRARY ${_ggml_backend}
135+
HINTS ${GGML_BACKEND_DIR} ${GGML_LIB_DIR}
136+
NO_CMAKE_FIND_ROOT_PATH)
137+
138+
if (NOT ${_ggml_backend_pfx}_LIBRARY)
139+
message(DEBUG "Built backend ${${_ggml_backend_pfx}_LIBRARY} not found")
140+
continue()
141+
endif()
142+
else()
143+
find_library(${_ggml_backend_pfx}_LIBRARY ${_ggml_backend}
144+
REQUIRED
145+
HINTS ${GGML_LIB_DIR}
146+
NO_CMAKE_FIND_ROOT_PATH)
147+
endif()
136148

137149
message(STATUS "Found ${${_ggml_backend_pfx}_LIBRARY}")
138150

0 commit comments

Comments
 (0)