Cable 0.2.9: Fix gitinfo when no git

This commit is contained in:
Paweł Bylica 2018-08-08 11:48:37 +02:00
parent 623ebc288e
commit 28d2fd54ba
No known key found for this signature in database
GPG Key ID: 7A0C037434FE77EF
2 changed files with 10 additions and 5 deletions

View File

@ -10,7 +10,7 @@
#
# This is internal variable automaticaly updated with external tools.
# Use CABLE_VERSION variable if you need this information.
set(version 0.2.8)
set(version 0.2.9)
# For conveniance, add the project CMake module dir to module path.
set(module_dir ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

View File

@ -11,14 +11,19 @@ string(TIMESTAMP TIMESTAMP)
# Read the git info from a file. The gitinfo is suppose to update the file
# only if the information has changed.
file(STRINGS ${OUTPUT_DIR}/gitinfo.txt gitinfo)
list(GET gitinfo 0 describe)
list(GET gitinfo 1 GIT_BRANCH)
list(GET gitinfo 2 GIT_ORIGIN_URL)
list(LENGTH gitinfo gitinfo_len)
if(gitinfo_len LESS 3)
message(WARNING "Git info not available")
else()
list(GET gitinfo 0 describe)
list(GET gitinfo 1 GIT_BRANCH)
list(GET gitinfo 2 GIT_ORIGIN_URL)
endif()
# The output of `git describe --always --long --tags --match=v*`.
string(REGEX MATCH "(v(.+)-([0-9]+)-g)?([0-9a-f]+)(-dirty)?" match "${describe}")
if(NOT match)
if(DEFINED describe AND NOT match)
message(WARNING "Cannot parse git describe: ${describe}")
endif()