refactor: set GIT_SHA_SHORT with git command
This commit is contained in:
committed by
Chris Rizzitello
parent
c05a87b716
commit
7656b49f1b
@ -32,6 +32,12 @@ set(DESKFLOW_VERSION_TWEAK 0)
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
|
||||
find_package(Git)
|
||||
if(GIT_FOUND)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} rev-parse --short=8 HEAD
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE GIT_SHA_SHORT
|
||||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} describe --long --match v* --always
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
|
||||
@ -22,12 +22,6 @@ macro(configure_definitions)
|
||||
set(INTEG_TESTS_BIN integtests)
|
||||
set(UNIT_TESTS_BIN unittests)
|
||||
|
||||
if(NOT "$ENV{GIT_SHA}" STREQUAL "")
|
||||
# Shorten the Git SHA to 8 chars for readability
|
||||
string(SUBSTRING "$ENV{GIT_SHA}" 0 8 GIT_SHA_SHORT)
|
||||
message(STATUS "Short Git SHA: ${GIT_SHA_SHORT}")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
message(STATUS "Disabling debug build")
|
||||
add_definitions(-DNDEBUG)
|
||||
|
||||
Reference in New Issue
Block a user