File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -76,21 +76,19 @@ option(LLAMA_BUILD_EXAMPLES "llama: build examples" ${LLAMA_STANDALONE})
7676# Build info header
7777#
7878
79- # Write header template to binary dir to keep source directory clean
80- file (WRITE "${CMAKE_BINARY_DIR } /BUILD_INFO.h.in" "\
81- #ifndef BUILD_INFO_H\n\
82- #define BUILD_INFO_H\n\
83- \n\
84- #define BUILD_NUMBER @BUILD_NUMBER@\n\
85- #define BUILD_COMMIT \" @BUILD_COMMIT@\"\n\
86- \n\
87- #endif // BUILD_INFO_H\n\
88- " )
89-
9079# Generate initial build-info.h
9180include (${CMAKE_CURRENT_SOURCE_DIR } /scripts/build-info.cmake )
9281
9382if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR } /.git" )
83+ set (GIT_DIR "${CMAKE_CURRENT_SOURCE_DIR } /.git" )
84+
85+ # Is git submodule
86+ if (NOT IS_DIRECTORY "${GIT_DIR} " )
87+ file (READ ${GIT_DIR} REAL_GIT_DIR_LINK )
88+ string (REGEX REPLACE "gitdir: (.*)\n $" "\\ 1" REAL_GIT_DIR ${REAL_GIT_DIR_LINK} )
89+ set (GIT_DIR "${CMAKE_CURRENT_SOURCE_DIR } /${REAL_GIT_DIR} " )
90+ endif ()
91+
9492 # Add a custom target for build-info.h
9593 add_custom_target (BUILD_INFO ALL DEPENDS "${CMAKE_CURRENT_SOURCE_DIR } /build-info.h" )
9694
@@ -100,7 +98,7 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
10098 COMMENT "Generating build details from Git"
10199 COMMAND ${CMAKE_COMMAND } -P "${CMAKE_CURRENT_SOURCE_DIR } /scripts/build-info.cmake"
102100 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR }
103- DEPENDS "${CMAKE_CURRENT_SOURCE_DIR } /.git /index"
101+ DEPENDS "${GIT_DIR} /index"
104102 VERBATIM
105103 )
106104else ()
Original file line number Diff line number Diff line change 1- set (TEMPLATE_FILE "${CMAKE_BINARY_DIR } /BUILD_INFO .h.in" )
1+ set (TEMPLATE_FILE "${CMAKE_CURRENT_SOURCE_DIR } /scripts/build-info .h.in" )
22set (HEADER_FILE "${CMAKE_CURRENT_SOURCE_DIR } /build-info.h" )
33set (BUILD_NUMBER 0)
44set (BUILD_COMMIT "unknown" )
Original file line number Diff line number Diff line change 1+ #ifndef BUILD_INFO_H
2+ #define BUILD_INFO_H
3+
4+ #define BUILD_NUMBER @BUILD_NUMBER@
5+ #define BUILD_COMMIT "@BUILD_COMMIT@"
6+
7+ #endif // BUILD_INFO_H
You can’t perform that action at this time.
0 commit comments