Change git command working directory to this project (#796)
If this project is used as subproject of another CMake project, then git commands will fail because git will be executed from wrong location.
This commit is contained in:
committed by
GitHub
parent
f8143d5419
commit
34b68d6eab
@@ -14,7 +14,7 @@ set(_VERSIONING_MODULE_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE INTERNAL "Versionin
|
||||
# Get tag (expected: v1.2.3 or 1.2.3 or 1.2.3-12-gHASH)
|
||||
execute_process(
|
||||
COMMAND git describe --tags --dirty
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_DESC_RAW
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
@@ -35,12 +35,14 @@ set(PROJECT_VERSION_STRING
|
||||
# Commit hash (full + short)
|
||||
execute_process(
|
||||
COMMAND git rev-parse HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE PROJECT_GIT_HASH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
execute_process(
|
||||
COMMAND git rev-parse --short HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE PROJECT_GIT_HASH_SHORT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user