@@ -7,51 +7,59 @@ project(linuxdeployqt)
7
7
8
8
find_program (GIT git)
9
9
10
- # make sure Git revision ID and latest tag is not stored in the CMake cache
11
- # otherwise, one would have to reset the CMake cache on every new commit to make sure the Git commit ID is up to date
12
- unset (GIT_COMMIT CACHE )
13
- unset (GIT_LATEST_TAG CACHE )
14
-
15
10
if ("${GIT} " STREQUAL "GIT-NOTFOUND" )
16
- message (FATAL_ERROR "Could not find git" )
17
- endif ()
11
+ message (WARNING "Could not find git, commit and tag info cannot be updated" )
18
12
19
- # read Git revision ID and latest tag number
20
- execute_process (
21
- COMMAND "${GIT} " rev-parse --short HEAD
22
- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
23
- OUTPUT_VARIABLE GIT_COMMIT
24
- OUTPUT_STRIP_TRAILING_WHITESPACE
25
- RESULT_VARIABLE GIT_COMMIT_RESULT
26
- )
27
- if (NOT GIT_COMMIT_RESULT EQUAL 0)
28
- message (FATAL_ERROR "Failed to determine git commit ID" )
29
- endif ()
30
- mark_as_advanced (GIT_COMMIT GIT_COMMIT_RESULT)
13
+ if (NOT GIT_COMMIT)
14
+ message (FATAL_ERROR "Commit ID not set, please call with -DGIT_COMMIT=..." )
15
+ endif ()
31
16
32
- execute_process (
33
- COMMAND "${GIT} " rev-list --tags --skip=1 --max-count=1
34
- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
35
- OUTPUT_VARIABLE GIT_TAG_ID
36
- OUTPUT_STRIP_TRAILING_WHITESPACE
37
- RESULT_VARIABLE GIT_TAG_ID_RESULT
38
- )
39
- if (NOT GIT_TAG_ID_RESULT EQUAL 0)
40
- message (FATAL_ERROR "Failed to determine git tag ID" )
41
- endif ()
42
- mark_as_advanced (GIT_TAG_ID GIT_TAG_ID_RESULT)
17
+ if (NOT GIT_TAG_NAME)
18
+ message (FATAL_ERROR "Tag name not set, please call with -DGIT_TAG_NAME=..." )
19
+ endif ()
20
+ else ()
21
+ # make sure Git revision ID and latest tag is not stored in the CMake cache
22
+ # otherwise, one would have to reset the CMake cache on every new commit to make sure the Git commit ID is up to date
23
+ unset (GIT_COMMIT CACHE )
24
+ unset (GIT_LATEST_TAG CACHE )
43
25
44
- execute_process (
45
- COMMAND "${GIT} " describe --tags ${GIT_TAG_ID} --abbrev=0
46
- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
47
- OUTPUT_VARIABLE GIT_TAG_NAME
48
- OUTPUT_STRIP_TRAILING_WHITESPACE
49
- RESULT_VARIABLE GIT_TAG_NAME_RESULT
50
- )
51
- if (NOT GIT_TAG_NAME_RESULT EQUAL 0)
52
- message (FATAL_ERROR "Failed to determine git tag name" )
26
+ # read Git revision ID and latest tag number
27
+ execute_process (
28
+ COMMAND "${GIT} " rev-parse --short HEAD
29
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
30
+ OUTPUT_VARIABLE GIT_COMMIT
31
+ OUTPUT_STRIP_TRAILING_WHITESPACE
32
+ RESULT_VARIABLE GIT_COMMIT_RESULT
33
+ )
34
+ if (NOT GIT_COMMIT_RESULT EQUAL 0)
35
+ message (FATAL_ERROR "Failed to determine git commit ID" )
36
+ endif ()
37
+ mark_as_advanced (GIT_COMMIT GIT_COMMIT_RESULT)
38
+
39
+ execute_process (
40
+ COMMAND "${GIT} " rev-list --tags --skip=1 --max-count=1
41
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
42
+ OUTPUT_VARIABLE GIT_TAG_ID
43
+ OUTPUT_STRIP_TRAILING_WHITESPACE
44
+ RESULT_VARIABLE GIT_TAG_ID_RESULT
45
+ )
46
+ if (NOT GIT_TAG_ID_RESULT EQUAL 0)
47
+ message (FATAL_ERROR "Failed to determine git tag ID" )
48
+ endif ()
49
+ mark_as_advanced (GIT_TAG_ID GIT_TAG_ID_RESULT)
50
+
51
+ execute_process (
52
+ COMMAND "${GIT} " describe --tags ${GIT_TAG_ID} --abbrev=0
53
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
54
+ OUTPUT_VARIABLE GIT_TAG_NAME
55
+ OUTPUT_STRIP_TRAILING_WHITESPACE
56
+ RESULT_VARIABLE GIT_TAG_NAME_RESULT
57
+ )
58
+ if (NOT GIT_TAG_NAME_RESULT EQUAL 0)
59
+ message (FATAL_ERROR "Failed to determine git tag name" )
60
+ endif ()
61
+ mark_as_advanced (GIT_TAG_NAME GIT_TAG_NAME_RESULT)
53
62
endif ()
54
- mark_as_advanced (GIT_TAG_NAME GIT_TAG_NAME_RESULT)
55
63
56
64
# set version and build number
57
65
set (VERSION 1-alpha)
0 commit comments