comparison cmake/HGVersion.cmake @ 495:7a8f5b85fd9a

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

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