1# Copyright (c) PLUMgrid, Inc. 2# Licensed under the Apache License, Version 2.0 (the "License") 3if(NOT REVISION) 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) 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}") 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() 22else() 23 set(REVISION_LAST "${REVISION}") 24endif() 25 26# strip leading 'v', and make unique for the tag 27message(STATUS "Revision is ${REVISION}") 28