annotate cmake/HGVersion.cmake @ 572:2459a7122532

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

http://wald.intevation.org/projects/trustbridge/