forked from Mirrors/openclonk
cmake: Read Mercurial revision from .hg_archival.txt if available
This way cmake will generate a correct C4Version.h from source tarballs generated by hg archive.scancodes-fix
parent
32028fd903
commit
fd4540d573
20
Version.txt
20
Version.txt
|
@ -35,12 +35,20 @@ SET(C4VERSIONEXTRA " Alpha")
|
|||
############################################################################
|
||||
# Get revision from Mercurial
|
||||
############################################################################
|
||||
|
||||
# Note: This will not work for source distributions!
|
||||
execute_process(WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
COMMAND "hg" "id" "--id"
|
||||
OUTPUT_VARIABLE C4REVISION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.hg_archival.txt")
|
||||
# Archives generated by hg archive
|
||||
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/.hg_archival.txt" C4REVISION
|
||||
LIMIT_COUNT 1
|
||||
REGEX "node: [0-9a-f]+"
|
||||
)
|
||||
string(SUBSTRING "${C4REVISION}" 6 12 C4REVISION)
|
||||
else()
|
||||
# Working copies
|
||||
execute_process(WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
COMMAND "hg" "id" "--id"
|
||||
OUTPUT_VARIABLE C4REVISION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
endif()
|
||||
|
||||
############################################################################
|
||||
# Build version strings
|
||||
|
|
Loading…
Reference in New Issue