Guard against adding to cache variable twice

This commit is contained in:
Mason M 2025-01-23 09:43:51 -04:00
parent b14e8294b1
commit ea0a85abae
2 changed files with 9 additions and 6 deletions

View File

@ -278,9 +278,8 @@ execute_process(COMMAND ${GIT_EXE} rev-list --count HEAD
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
) )
if(${GGML_BUILD_NUMBER} EQUAL 1) if(GGML_BUILD_NUMBER EQUAL 1)
message(WARNING message(WARNING "GGML build version fixed at 1 likely due to a shallow clone.")
"GGML build version fixed at 1 likely due to a shallow clone.")
endif() endif()
execute_process(COMMAND ${GIT_EXE} rev-parse --short HEAD execute_process(COMMAND ${GIT_EXE} rev-parse --short HEAD

View File

@ -252,11 +252,15 @@ function(ggml_add_backend_library backend)
endif() endif()
if(NOT GGML_AVAILABLE_BACKENDS) if(NOT GGML_AVAILABLE_BACKENDS)
set(GGML_AVAILABLE_BACKENDS "${backend}" CACHE INTERNAL "List of backends for cmake package") set(GGML_AVAILABLE_BACKENDS "${backend}"
CACHE INTERNAL "List of backends for cmake package")
else() else()
list(FIND GGML_AVAILABLE_BACKENDS "${backend}" has_backend)
if(has_backend EQUAL -1)
set(GGML_AVAILABLE_BACKENDS "${GGML_AVAILABLE_BACKENDS};${backend}" set(GGML_AVAILABLE_BACKENDS "${GGML_AVAILABLE_BACKENDS};${backend}"
CACHE INTERNAL "List of backends for cmake package") CACHE INTERNAL "List of backends for cmake package")
endif() endif()
endif()
endfunction() endfunction()
function(ggml_add_backend backend) function(ggml_add_backend backend)