annotate cmake/HGVersion.cmake @ 37:b574990e90a5

Update Format spec for additional handling
author Andre Heinecke <andre.heinecke@intevation.de>
date Fri, 15 Apr 2016 15:15:44 +0200
parents 49cd5cc0b072
children
rev   line source
0
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
1 # Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
2 # Software engineering by Intevation GmbH
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
3 #
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
4 # This file is Free Software under the GNU GPL (v>=2)
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
5 # and comes with ABSOLUTELY NO WARRANTY!
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
6 # See LICENSE.txt for details.
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
7
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
8 # This makes some variables available to generate a nice version number for
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
9 # hg managed repositories.
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
10 # It sets HG_REVISION_TAG to the value of the latest tag
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
11 # HG_REVISION_DIST to the differences between the tag and the current tip
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
12 # HG_REVISION_ID to the actual revision
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
13 # based on code found in the lemon graph library https://lemon.cs.elte.hu
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
14 # HG_REVISON to a nice combination of those.
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
15 find_package(Hg)
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
16 if (HG_FOUND)
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
17 EXECUTE_PROCESS(
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
18 COMMAND
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
19 hg log -r. --template "{latesttag}"
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
20 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
21 OUTPUT_VARIABLE HG_REVISION_TAG
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
22 ERROR_QUIET
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
23 OUTPUT_STRIP_TRAILING_WHITESPACE
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
24 )
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
25 EXECUTE_PROCESS(
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
26 COMMAND
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
27 hg log -r. --template "{latesttagdistance}"
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
28 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
29 OUTPUT_VARIABLE HG_REVISION_DIST
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
30 ERROR_QUIET
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
31 OUTPUT_STRIP_TRAILING_WHITESPACE
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
32 )
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
33 EXECUTE_PROCESS(
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
34 COMMAND
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
35 hg log -r. --template "{node|short}"
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
36 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
37 OUTPUT_VARIABLE HG_REVISION_ID
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
38 ERROR_QUIET
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
39 OUTPUT_STRIP_TRAILING_WHITESPACE
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
40 )
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
41
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
42 IF(HG_REVISION_TAG STREQUAL "")
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
43 SET(HG_REVISION_ID "hg-tip")
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
44 ELSE()
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
45 IF(HG_REVISION_TAG STREQUAL "null")
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
46 SET(HG_REVISION_TAG "trunk")
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
47 ELSEIF(HG_REVISION_TAG MATCHES "^r")
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
48 STRING(SUBSTRING ${HG_REVISION_TAG} 1 -1 HG_REVISION_TAG)
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
49 ENDIF()
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
50 IF(HG_REVISION_DIST STREQUAL "0")
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
51 SET(HG_REVISION ${HG_REVISION_TAG})
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
52 ELSE()
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
53 SET(HG_REVISION
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
54 "${HG_REVISION_TAG}+${HG_REVISION_DIST}-${HG_REVISION_ID}")
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
55 ENDIF()
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
56 ENDIF()
49cd5cc0b072 Initial commit of project template (based on RetraceIT)
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
57 ENDIF()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)