File tree Expand file tree Collapse file tree 3 files changed +18
-13
lines changed Expand file tree Collapse file tree 3 files changed +18
-13
lines changed Original file line number Diff line number Diff line change @@ -76,21 +76,19 @@ option(LLAMA_BUILD_EXAMPLES "llama: build examples" ${LLAMA_STANDALONE})
76
76
# Build info header
77
77
#
78
78
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
-
90
79
# Generate initial build-info.h
91
80
include (${CMAKE_CURRENT_SOURCE_DIR} /scripts/build-info.cmake )
92
81
93
82
if (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
+
94
92
# Add a custom target for build-info.h
95
93
add_custom_target (BUILD_INFO ALL DEPENDS "${CMAKE_CURRENT_SOURCE_DIR} /build-info.h" )
96
94
@@ -100,7 +98,7 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
100
98
COMMENT "Generating build details from Git"
101
99
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_SOURCE_DIR} /scripts/build-info.cmake"
102
100
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
103
- DEPENDS "${CMAKE_CURRENT_SOURCE_DIR} /.git /index"
101
+ DEPENDS "${GIT_DIR} /index"
104
102
VERBATIM
105
103
)
106
104
else ()
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" )
2
2
set (HEADER_FILE "${CMAKE_CURRENT_SOURCE_DIR} /build-info.h" )
3
3
set (BUILD_NUMBER 0 )
4
4
set (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