Fix cmake version detection from git tag.

This commit is contained in:
James Goppert
2017-01-13 01:11:14 -08:00
committed by Lorenz Meier
parent 249d7f00ce
commit b1173f1f62
2 changed files with 19 additions and 2 deletions
+17
View File
@@ -0,0 +1,17 @@
import subprocess
import os
import argparse
p = argparse.ArgumentParser('finds major minor patch version from git tag')
p.add_argument('--root', help="root of git repo", default=".")
args = p.parse_args()
os.chdir(args.root)
p= subprocess.Popen(
'git describe --always --tags'.split(),
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
res = stdout.split('-')[0].split('.')
major = res[0].replace('v','')
minor = res[1]
patch = res[2]
print("{:s}.{:s}.{:s}".format(major, minor, patch))