Skip to content

Commit fbc1569

Browse files
committed
cmake: Allow to configure GGML_BUILD_NUMBER with file
This will enable llama-cpp-python to generate the file during sdist build and include it into the final tarball. The file then will be picked up by the package build to include the correct version, even without full git checkout included. Related: abetlen/llama-cpp-python#1979 Signed-off-by: Ihar Hrachyshka <[email protected]>
1 parent 4375415 commit fbc1569

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Diff for: ggml/CMakeLists.txt

+9
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,15 @@ endif()
287287

288288
# Generate version info based on git commit.
289289

290+
# First try to get the build number from the file.
291+
if(NOT DEFINED GGML_BUILD_NUMBER)
292+
if(EXISTS ${CMAKE_SOURCE_DIR}/.ggml_build_number)
293+
file(STRINGS ${CMAKE_SOURCE_DIR}/.ggml_build_number GGML_BUILD_NUMBER)
294+
# Assume the first line contains the desired version.
295+
list(GET GGML_BUILD_NUMBER 0 GGML_BUILD_NUMBER)
296+
endif()
297+
endif()
298+
290299
if(NOT DEFINED GGML_BUILD_NUMBER)
291300
find_program(GIT_EXE NAMES git git.exe REQUIRED NO_CMAKE_FIND_ROOT_PATH)
292301
execute_process(COMMAND ${GIT_EXE} rev-list --count HEAD

0 commit comments

Comments
 (0)