mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2024-12-25 22:08:46 +01: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:
parent
bf4b22ffe4
commit
9daff419f6
@ -76,21 +76,19 @@ option(LLAMA_BUILD_EXAMPLES "llama: build examples" ${LLAMA_STANDALONE})
|
|||||||
# Build info header
|
# 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
|
# Generate initial build-info.h
|
||||||
include(${CMAKE_CURRENT_SOURCE_DIR}/scripts/build-info.cmake)
|
include(${CMAKE_CURRENT_SOURCE_DIR}/scripts/build-info.cmake)
|
||||||
|
|
||||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
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 a custom target for build-info.h
|
||||||
add_custom_target(BUILD_INFO ALL DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/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"
|
COMMENT "Generating build details from Git"
|
||||||
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_SOURCE_DIR}/scripts/build-info.cmake"
|
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_SOURCE_DIR}/scripts/build-info.cmake"
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/.git/index"
|
DEPENDS "${GIT_DIR}/index"
|
||||||
VERBATIM
|
VERBATIM
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
set(TEMPLATE_FILE "${CMAKE_BINARY_DIR}/BUILD_INFO.h.in")
|
set(TEMPLATE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/scripts/build-info.h.in")
|
||||||
set(HEADER_FILE "${CMAKE_CURRENT_SOURCE_DIR}/build-info.h")
|
set(HEADER_FILE "${CMAKE_CURRENT_SOURCE_DIR}/build-info.h")
|
||||||
set(BUILD_NUMBER 0)
|
set(BUILD_NUMBER 0)
|
||||||
set(BUILD_COMMIT "unknown")
|
set(BUILD_COMMIT "unknown")
|
||||||
|
7
scripts/build-info.h.in
Normal file
7
scripts/build-info.h.in
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#ifndef BUILD_INFO_H
|
||||||
|
#define BUILD_INFO_H
|
||||||
|
|
||||||
|
#define BUILD_NUMBER @BUILD_NUMBER@
|
||||||
|
#define BUILD_COMMIT "@BUILD_COMMIT@"
|
||||||
|
|
||||||
|
#endif // BUILD_INFO_H
|
Loading…
Reference in New Issue
Block a user