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