Skip to content

Commit 0150cf2

Browse files
committed
backend_selection
1 parent 2ee2381 commit 0150cf2

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

ggml/cmake/ggml-config.cmake.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ set_and_check(GGML_INCLUDE_DIR "@PACKAGE_GGML_INCLUDE_INSTALL_DIR@")
108108
set_and_check(GGML_LIB_DIR "@PACKAGE_GGML_LIB_INSTALL_DIR@")
109109
#set_and_check(GGML_BIN_DIR "@PACKAGE_GGML_BIN_INSTALL_DIR@")
110110

111+
# Include the exported targets file
112+
include("${CMAKE_CURRENT_LIST_DIR}/ggml-targets.cmake")
113+
111114
if(NOT TARGET ggml::ggml)
112115
find_package(Threads REQUIRED)
113116

ggml/src/CMakeLists.txt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,21 @@ function(ggml_add_backend_library backend)
243243
# write the shared library to the output directory
244244
set_target_properties(${backend} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
245245
target_compile_definitions(${backend} PRIVATE GGML_BACKEND_DL)
246-
add_dependencies(ggml ${backend})
246+
# Do not add dependency, the User will have to explicitely build and install
247+
# the available `ggml::ggml-*` backend targets. This is for better integration
248+
# with cmake-bare
249+
# add_dependencies(ggml ${backend})
250+
247251
if (GGML_BACKEND_DIR)
248-
install(TARGETS ${backend} LIBRARY DESTINATION ${GGML_BACKEND_DIR})
252+
install(TARGETS ${backend}
253+
EXPORT ggml-targets
254+
LIBRARY DESTINATION ${GGML_BACKEND_DIR}
255+
RUNTIME DESTINATION ${GGML_BACKEND_DIR})
249256
else()
250-
install(TARGETS ${backend} LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR})
257+
install(TARGETS ${backend}
258+
EXPORT ggml-targets
259+
LIBRARY DESTINATION ${CMAKE_BINARY_DIR}
260+
RUNTIME DESTINATION ${CMAKE_BINARY_DIR})
251261
endif()
252262
else()
253263
add_library(${backend} ${ARGN})

0 commit comments

Comments
 (0)