andre@0: # Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik andre@0: # Software engineering by Intevation GmbH andre@0: # andre@0: # This file is Free Software under the GNU GPL (v>=2) andre@0: # and comes with ABSOLUTELY NO WARRANTY! andre@0: # See LICENSE.txt for details. andre@0: andre@0: # This makes some variables available to generate a nice version number for andre@0: # hg managed repositories. andre@0: # It sets HG_REVISION_TAG to the value of the latest tag andre@0: # HG_REVISION_DIST to the differences between the tag and the current tip andre@0: # HG_REVISION_ID to the actual revision andre@0: # based on code found in the lemon graph library https://lemon.cs.elte.hu andre@0: # HG_REVISON to a nice combination of those. andre@0: find_package(Hg) andre@0: if (HG_FOUND) andre@0: EXECUTE_PROCESS( andre@0: COMMAND andre@0: hg log -r. --template "{latesttag}" andre@0: WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} andre@0: OUTPUT_VARIABLE HG_REVISION_TAG andre@0: ERROR_QUIET andre@0: OUTPUT_STRIP_TRAILING_WHITESPACE andre@0: ) andre@0: EXECUTE_PROCESS( andre@0: COMMAND andre@0: hg log -r. --template "{latesttagdistance}" andre@0: WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} andre@0: OUTPUT_VARIABLE HG_REVISION_DIST andre@0: ERROR_QUIET andre@0: OUTPUT_STRIP_TRAILING_WHITESPACE andre@0: ) andre@0: EXECUTE_PROCESS( andre@0: COMMAND andre@0: hg log -r. --template "{node|short}" andre@0: WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} andre@0: OUTPUT_VARIABLE HG_REVISION_ID andre@0: ERROR_QUIET andre@0: OUTPUT_STRIP_TRAILING_WHITESPACE andre@0: ) andre@0: andre@0: IF(HG_REVISION_TAG STREQUAL "") andre@0: SET(HG_REVISION_ID "hg-tip") andre@0: ELSE() andre@0: IF(HG_REVISION_TAG STREQUAL "null") andre@0: SET(HG_REVISION_TAG "trunk") andre@0: ELSEIF(HG_REVISION_TAG MATCHES "^r") andre@0: STRING(SUBSTRING ${HG_REVISION_TAG} 1 -1 HG_REVISION_TAG) andre@0: ENDIF() andre@0: IF(HG_REVISION_DIST STREQUAL "0") andre@0: SET(HG_REVISION ${HG_REVISION_TAG}) andre@0: ELSE() andre@0: SET(HG_REVISION andre@0: "${HG_REVISION_TAG}+${HG_REVISION_DIST}-${HG_REVISION_ID}") andre@0: ENDIF() andre@0: ENDIF() andre@0: ENDIF()