[CMake]: Fix version in pkgconfig file (#6986)

This change checks if the current source directory is a git repository.
If this is not checked the git command picks the commit hash from
parent directory. e.g. when tarball is extracted in a packaging repository.
This commit is contained in:
Biswapriyo Nath 2021-12-11 05:10:21 +05:30 committed by GitHub
parent 956d11569e
commit b92bb0584d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -4,7 +4,7 @@ set(VERSION_PATCH 5)
set(VERSION_COMMIT 0)
find_program(GIT git)
if(GIT)
if(GIT AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
execute_process(
COMMAND ${GIT} describe --tags
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}