Mercurial > clickerconvert
comparison cmake/HGVersion.cmake @ 0:49cd5cc0b072
Initial commit of project template (based on RetraceIT)
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 07 Mar 2016 17:35:09 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:49cd5cc0b072 |
---|---|
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() |