diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,29 +12,47 @@ SET(LEMON_VERSION $ENV{LEMON_VERSION} CACHE STRING "LEMON version string.") ELSE() EXECUTE_PROCESS( - COMMAND ${PYTHON_EXECUTABLE} ./scripts/chg-len.py + COMMAND + hg log -r. --template "{latesttag}" WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - OUTPUT_VARIABLE HG_REVISION_PATH + OUTPUT_VARIABLE HG_REVISION_TAG ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE ) EXECUTE_PROCESS( - COMMAND hg id -i + COMMAND + hg log -r. --template "{latesttagdistance}" WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - OUTPUT_VARIABLE HG_REVISION + OUTPUT_VARIABLE HG_REVISION_DIST ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE ) - IF(HG_REVISION STREQUAL "") + EXECUTE_PROCESS( + COMMAND + hg log -r. --template "{node|short}" + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + OUTPUT_VARIABLE HG_REVISION_ID + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + IF(HG_REVISION_TAG STREQUAL "") SET(HG_REVISION_ID "hg-tip") ELSE() - IF(HG_REVISION_PATH STREQUAL "") - SET(HG_REVISION_ID ${HG_REVISION}) + IF(HG_REVISION_TAG STREQUAL "null") + SET(HG_REVISION_TAG "trunk") + ELSEIF(HG_REVISION_TAG MATCHES "^r") + STRING(SUBSTRING ${HG_REVISION_TAG} 1 -1 HG_REVISION_TAG) + ENDIF() + IF(HG_REVISION_DIST STREQUAL "0") + SET(HG_REVISION ${HG_REVISION_TAG}) ELSE() - SET(HG_REVISION_ID ${HG_REVISION_PATH}.${HG_REVISION}) + SET(HG_REVISION + "${HG_REVISION_TAG}+${HG_REVISION_DIST}-${HG_REVISION_ID}") ENDIF() ENDIF() - SET(LEMON_VERSION ${HG_REVISION_ID} CACHE STRING "LEMON version string.") + + SET(LEMON_VERSION ${HG_REVISION} CACHE STRING "LEMON version string.") ENDIF() SET(PROJECT_VERSION ${LEMON_VERSION})