blob: fb00408a9d14612a9d36f2158a8f0a6feb4f6376 [file] [log] [blame]
Brenden Blancod8acf6f2015-06-07 22:32:33 -07001# Copyright (c) PLUMgrid, Inc.
2# Licensed under the Apache License, Version 2.0 (the "License")
Brenden Blancof275d3d2015-07-06 23:41:23 -07003if(NOT REVISION)
troyengel9078ecb2015-11-09 19:51:32 -06004 get_git_head_revision(GIT_REFSPEC GIT_SHA1)
5 string(SUBSTRING "${GIT_SHA1}" 0 8 GIT_SHA1_SHORT)
6 git_describe(GIT_DESCRIPTION)
7 git_describe(GIT_TAG_LAST "--abbrev=0")
8 git_get_exact_tag(GIT_TAG_EXACT)
Brenden Blancof275d3d2015-07-06 23:41:23 -07009 string(SUBSTRING "${GIT_TAG_LAST}-${GIT_SHA1_SHORT}" 1 -1 REVISION)
10 if(GIT_TAG_EXACT)
11 string(SUBSTRING "${GIT_TAG_EXACT}" 1 -1 REVISION)
12 message(STATUS "Currently on Git tag ${GIT_TAG_EXACT}")
13 else ()
14 message(STATUS "Latest recognized Git tag is ${GIT_TAG_LAST}")
15 set(GIT_TAG_EXACT "")
16 endif()
17 message(STATUS "Git HEAD is ${GIT_SHA1}")
troyengel9078ecb2015-11-09 19:51:32 -060018 # rpm/deb packaging uses this, only works on whole tag numbers
19 if(NOT REVISION_LAST)
20 string(SUBSTRING "${GIT_TAG_LAST}" 1 -1 REVISION_LAST)
21 endif()
22else()
23 set(REVISION_LAST "${REVISION}")
Brenden Blancod8acf6f2015-06-07 22:32:33 -070024endif()
Brenden Blancod8acf6f2015-06-07 22:32:33 -070025
26# strip leading 'v', and make unique for the tag
27message(STATUS "Revision is ${REVISION}")