Skip to content

Commit

Permalink
Use the git commit hash as the version if not on a tag (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesWrigley authored Jun 12, 2024
1 parent 8c0bf3e commit 93129ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/version.cpp.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
const char* version = "@GIT_TAG@";
const char* version = "@GIT_REF@";
11 changes: 9 additions & 2 deletions version.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --dirty --match "v*"
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE GIT_TAG
OUTPUT_VARIABLE GIT_REF
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)

configure_file(${SRC} ${DST} @ONLY)
# If we're not on a tag, use the commit hash
if(NOT GIT_REF)
execute_process(COMMAND ${GIT_EXECUTABLE} describe --always --dirty
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE GIT_REF
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
endif()

configure_file(${SRC} ${DST} @ONLY)

0 comments on commit 93129ff

Please sign in to comment.