mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2025-06-26 19:55:04 +00:00
fix build-info.h for git submodules (#1289)
* make git build info work with submodules --------- Co-authored-by: Green Sky <green@g-s.xyz>
This commit is contained in:
@ -76,21 +76,19 @@ option(LLAMA_BUILD_EXAMPLES "llama: build examples" ${LLAMA_STANDALONE})
|
||||
# Build info header
|
||||
#
|
||||
|
||||
# Write header template to binary dir to keep source directory clean
|
||||
file(WRITE "${CMAKE_BINARY_DIR}/BUILD_INFO.h.in" "\
|
||||
#ifndef BUILD_INFO_H\n\
|
||||
#define BUILD_INFO_H\n\
|
||||
\n\
|
||||
#define BUILD_NUMBER @BUILD_NUMBER@\n\
|
||||
#define BUILD_COMMIT \"@BUILD_COMMIT@\"\n\
|
||||
\n\
|
||||
#endif // BUILD_INFO_H\n\
|
||||
")
|
||||
|
||||
# Generate initial build-info.h
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/scripts/build-info.cmake)
|
||||
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||
set(GIT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||
|
||||
# Is git submodule
|
||||
if(NOT IS_DIRECTORY "${GIT_DIR}")
|
||||
file(READ ${GIT_DIR} REAL_GIT_DIR_LINK)
|
||||
string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" REAL_GIT_DIR ${REAL_GIT_DIR_LINK})
|
||||
set(GIT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${REAL_GIT_DIR}")
|
||||
endif()
|
||||
|
||||
# Add a custom target for build-info.h
|
||||
add_custom_target(BUILD_INFO ALL DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/build-info.h")
|
||||
|
||||
@ -100,7 +98,7 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||
COMMENT "Generating build details from Git"
|
||||
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_SOURCE_DIR}/scripts/build-info.cmake"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/.git/index"
|
||||
DEPENDS "${GIT_DIR}/index"
|
||||
VERBATIM
|
||||
)
|
||||
else()
|
||||
|
Reference in New Issue
Block a user