From ea0a85abaedb63545a1de82cabafbc1587f73ab1 Mon Sep 17 00:00:00 2001 From: Mason M Date: Thu, 23 Jan 2025 09:43:51 -0400 Subject: [PATCH] Guard against adding to cache variable twice --- ggml/CMakeLists.txt | 5 ++--- ggml/src/CMakeLists.txt | 10 +++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ggml/CMakeLists.txt b/ggml/CMakeLists.txt index a6aa97d9d..17abdfede 100644 --- a/ggml/CMakeLists.txt +++ b/ggml/CMakeLists.txt @@ -278,9 +278,8 @@ execute_process(COMMAND ${GIT_EXE} rev-list --count HEAD OUTPUT_STRIP_TRAILING_WHITESPACE ) -if(${GGML_BUILD_NUMBER} EQUAL 1) - message(WARNING - "GGML build version fixed at 1 likely due to a shallow clone.") +if(GGML_BUILD_NUMBER EQUAL 1) + message(WARNING "GGML build version fixed at 1 likely due to a shallow clone.") endif() execute_process(COMMAND ${GIT_EXE} rev-parse --short HEAD diff --git a/ggml/src/CMakeLists.txt b/ggml/src/CMakeLists.txt index d4f383c55..8d2b948fb 100644 --- a/ggml/src/CMakeLists.txt +++ b/ggml/src/CMakeLists.txt @@ -252,10 +252,14 @@ function(ggml_add_backend_library backend) endif() if(NOT GGML_AVAILABLE_BACKENDS) - set(GGML_AVAILABLE_BACKENDS "${backend}" CACHE INTERNAL "List of backends for cmake package") - else() - set(GGML_AVAILABLE_BACKENDS "${GGML_AVAILABLE_BACKENDS};${backend}" + set(GGML_AVAILABLE_BACKENDS "${backend}" CACHE INTERNAL "List of backends for cmake package") + else() + list(FIND GGML_AVAILABLE_BACKENDS "${backend}" has_backend) + if(has_backend EQUAL -1) + set(GGML_AVAILABLE_BACKENDS "${GGML_AVAILABLE_BACKENDS};${backend}" + CACHE INTERNAL "List of backends for cmake package") + endif() endif() endfunction()