aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2016-03-13 17:07:04 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2016-03-13 17:07:04 +0100
commita83ef111c8d527f9d8a6ef764d55c5baa06d5b54 (patch)
treee2f9fc73b25efcd5ab64fb443454b48e3e787729
parent90842c23a29aea65aa29904bdd06c2b75d5cc9e3 (diff)
downloadxK-a83ef111c8d527f9d8a6ef764d55c5baa06d5b54.tar.gz
xK-a83ef111c8d527f9d8a6ef764d55c5baa06d5b54.tar.xz
xK-a83ef111c8d527f9d8a6ef764d55c5baa06d5b54.zip
Fix git commit tracking
-rw-r--r--CMakeLists.txt14
1 files changed, 11 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fc06bb6..aada20f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,8 +19,16 @@ set (project_version "0.9.2")
# we could also detect dirty worktrees but that's very hard to get right.
find_package (Git)
set (git_head "${PROJECT_SOURCE_DIR}/.git/HEAD")
-if (GIT_FOUND AND EXISTS ${git_head})
- configure_file (${git_head} git-head.tag COPYONLY)
+if (GIT_FOUND AND EXISTS "${git_head}")
+ configure_file ("${git_head}" git-head.tag COPYONLY)
+ file (READ "${git_head}" git_head_content)
+ if (git_head_content MATCHES "^ref: ([^\r\n]+)")
+ set (git_ref "${PROJECT_SOURCE_DIR}/.git/${CMAKE_MATCH_1}")
+ if (EXISTS "${git_ref}")
+ configure_file ("${git_ref}" git-ref.tag COPYONLY)
+ endif (EXISTS "${git_ref}")
+ endif (git_head_content MATCHES "^ref: ([^\r\n]+)")
+
execute_process (COMMAND ${GIT_EXECUTABLE} describe --tags --match v*
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE git_describe_result
@@ -28,7 +36,7 @@ if (GIT_FOUND AND EXISTS ${git_head})
if (NOT git_describe_result)
string (REGEX REPLACE "^v" "" project_version "${git_describe}")
endif (NOT git_describe_result)
-endif (GIT_FOUND AND EXISTS ${git_head})
+endif (GIT_FOUND AND EXISTS "${git_head}")
# Dashes make filenames confusing and upset packaging software
string (REPLACE "-" "+" project_version_safe "${project_version}")