Skip to content

Commit

Permalink
perf: add git_AnyUncommittedChanges to default template (#116)
Browse files Browse the repository at this point in the history
Signed-off-by: msclock <msclock@qq.com>
  • Loading branch information
msclock authored Jul 24, 2024
1 parent 6ba68d4 commit a157241
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cmake/configure/GitTools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ include_guard(GLOBAL)

#[[
A function to generate a git version header using the current
project git meta.
project git meta. It requires the following variables to be set:
- CMAKE_PROJECT_GIT_COMMIT*: git commit information (see below)
- CMAKE_PROJECT_VERSION: project version number (major.minor.patch.tweak)
- CMAKE_PROJECT_VERSION_<MAJOR|MINOR|PATCH|TWEAK>: project version numbers (major, minor, patch, tweak)

Arguments:
CONFIGURE_HEADER_FILE - git header configuration content.
Expand Down Expand Up @@ -98,6 +101,12 @@ inline const char* git_ProjectVersionTweak() {
return R\"(@CMAKE_PROJECT_VERSION_TWEAK@)\"\;
}
/// Were there any uncommitted changes that won't be reflected
/// in the CommitID?
inline bool git_AnyUncommittedChanges() {
return @CMAKE_PROJECT_GIT_COMMIT_DIRTY@ == 1\;
}
/// The commit author's name.
inline const char* git_AuthorName() {
return R\"(@CMAKE_PROJECT_GIT_COMMIT_AUTHOR_NAME@)\"\;
Expand Down Expand Up @@ -239,6 +248,10 @@ inline const StringOrView& ProjectVersionTweak() {
static const StringOrView kValue = internal::InitString(git_ProjectVersionTweak())\;
return kValue\;
}
inline bool AnyUncommittedChanges() {
static const bool kValue = git_AnyUncommittedChanges()\;
return kValue\;
}
inline const StringOrView& AuthorName() {
static const StringOrView kValue = internal::InitString(git_AuthorName())\;
return kValue\;
Expand Down

0 comments on commit a157241

Please sign in to comment.