From 5b4c12e92eb7dec0bafdf227f0d25b65fa6affed Mon Sep 17 00:00:00 2001 From: Mason M Date: Thu, 23 Jan 2025 05:58:56 -0400 Subject: [PATCH] Add build numbers to ggml find-package --- ggml/CMakeLists.txt | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/ggml/CMakeLists.txt b/ggml/CMakeLists.txt index 0bf0898a4..5a265cead 100644 --- a/ggml/CMakeLists.txt +++ b/ggml/CMakeLists.txt @@ -272,9 +272,25 @@ endif() include(GNUInstallDirs) include(CMakePackageConfigHelpers) -set(GGML_BUILD_NUMBER ${BUILD_NUMBER}) -set(GGML_BUILD_COMMIT ${BUILD_COMMIT}) -set(GGML_INSTALL_VERSION 0.0.${BUILD_NUMBER}) +find_program(GIT_EXE NAMES git git.exe REQUIRED NO_CMAKE_FIND_ROOT_PATH) +execute_process(COMMAND ${GIT_EXE} rev-list --count HEAD + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE GGML_BUILD_NUMBER + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +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 + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE GGML_BUILD_COMMIT + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +set(GGML_INSTALL_VERSION 0.0.${GGML_BUILD_NUMBER}) set(GGML_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH "Location of header files") set(GGML_LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Location of library files")