Brenden Blanco | d8acf6f | 2015-06-07 22:32:33 -0700 | [diff] [blame] | 1 | # Copyright (c) PLUMgrid, Inc. |
| 2 | # Licensed under the Apache License, Version 2.0 (the "License") |
Brenden Blanco | f275d3d | 2015-07-06 23:41:23 -0700 | [diff] [blame] | 3 | if(NOT REVISION) |
troyengel | 9078ecb | 2015-11-09 19:51:32 -0600 | [diff] [blame] | 4 | 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 Blanco | f275d3d | 2015-07-06 23:41:23 -0700 | [diff] [blame] | 9 | 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}") |
troyengel | 9078ecb | 2015-11-09 19:51:32 -0600 | [diff] [blame] | 18 | # 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() |
| 22 | else() |
| 23 | set(REVISION_LAST "${REVISION}") |
Brenden Blanco | d8acf6f | 2015-06-07 22:32:33 -0700 | [diff] [blame] | 24 | endif() |
Brenden Blanco | d8acf6f | 2015-06-07 22:32:33 -0700 | [diff] [blame] | 25 | |
| 26 | # strip leading 'v', and make unique for the tag |
| 27 | message(STATUS "Revision is ${REVISION}") |