author | unc0rr |
Wed, 22 Jan 2014 23:06:50 +0400 | |
changeset 10055 | f738693be9be |
parent 10025 | ec966363adbe |
child 15449 | 6e09555b25b4 |
permissions | -rw-r--r-- |
9150
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
1 |
#detect Mercurial revision and init rev/hash information |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
2 |
find_program(HGCOMMAND hg) |
9933 | 3 |
find_program(GITCOMMAND git) |
10025
ec966363adbe
new cmake option NOVERSIONINFOUPDATE -- to be used if source is in a git/repo that is NOT the hedgewars repo
sheepluva
parents:
9937
diff
changeset
|
4 |
if(EXISTS ${CMAKE_SOURCE_DIR}/.hg AND HGCOMMAND AND NOT NOVERSIONINFOUPDATE) |
9150
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
5 |
execute_process(COMMAND ${HGCOMMAND} identify -in |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
6 |
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
7 |
OUTPUT_VARIABLE internal_version |
9937 | 8 |
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE |
9933 | 9 |
) |
9150
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
10 |
#check local repo status |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
11 |
string(REGEX REPLACE "[^+]" "" HGCHANGED ${internal_version}) |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
12 |
string(REGEX REPLACE "[0-9a-zA-Z]+(.*) ([0-9]+)(.*)" "\\2" HEDGEWARS_REVISION ${internal_version}) |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
13 |
string(REGEX REPLACE "([0-9a-zA-Z]+)(.*) [0-9]+(.*)" "\\1" HEDGEWARS_HASH ${internal_version}) |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
14 |
|
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
15 |
if(HGCHANGED) |
9151 | 16 |
message("*** You have uncommitted changes in your repository ***") |
9150
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
17 |
endif() |
9933 | 18 |
|
9150
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
19 |
#let's assume that if you have hg you might be interested in debugging |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
20 |
set(default_build_type "DEBUG") |
9933 | 21 |
|
22 |
#write down hash and rev for easy picking should hg be missing |
|
23 |
file(WRITE "${CMAKE_SOURCE_DIR}/share/version_info.txt" "Hedgewars versioning information, do not modify\nrev ${HEDGEWARS_REVISION}\nhash ${HEDGEWARS_HASH}\n") |
|
10025
ec966363adbe
new cmake option NOVERSIONINFOUPDATE -- to be used if source is in a git/repo that is NOT the hedgewars repo
sheepluva
parents:
9937
diff
changeset
|
24 |
elseif(EXISTS ${CMAKE_SOURCE_DIR}/.git AND GITCOMMAND AND NOT NOVERSIONINFOUPDATE) |
9933 | 25 |
execute_process(COMMAND ${GITCOMMAND} rev-parse --short HEAD |
26 |
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} |
|
27 |
OUTPUT_VARIABLE HEDGEWARS_HASH |
|
9937 | 28 |
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE |
9933 | 29 |
) |
9937 | 30 |
set(HEDGEWARS_REVISION "GIT") |
9933 | 31 |
|
32 |
#let's assume that if you have git you might be interested in debugging |
|
33 |
set(default_build_type "DEBUG") |
|
34 |
||
9150
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
35 |
#write down hash and rev for easy picking should hg be missing |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
36 |
file(WRITE "${CMAKE_SOURCE_DIR}/share/version_info.txt" "Hedgewars versioning information, do not modify\nrev ${HEDGEWARS_REVISION}\nhash ${HEDGEWARS_HASH}\n") |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
37 |
else() |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
38 |
set(default_build_type "RELEASE") |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
39 |
# when compiling outside rev control, fetch revision and hash information from version_info.txt |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
40 |
find_file(version_info version_info.txt PATH ${CMAKE_SOURCE_DIR}/share) |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
41 |
if(version_info) |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
42 |
file(STRINGS ${version_info} internal_version REGEX "rev") |
9937 | 43 |
string(REGEX REPLACE "rev ([GIT0-9]*)" "\\1" HEDGEWARS_REVISION ${internal_version}) |
9150
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
44 |
file(STRINGS ${version_info} internal_version REGEX "hash") |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
45 |
string(REGEX REPLACE "hash ([a-zA-Z0-9]*)" "\\1" HEDGEWARS_HASH ${internal_version}) |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
46 |
else() |
9151 | 47 |
message(WARNING "${CMAKE_SOURCE_DIR}/share/version_info.txt not found, revision information " |
48 |
"will be incorrect!!! Contact your source provider to fix this!") |
|
9150
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
49 |
set(HEDGEWARS_REVISION "0000") |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
50 |
set(HEDGEWARS_HASH "unknown") |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
51 |
endif() |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
52 |
endif() |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
53 |
|
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
54 |