blob: bd6484991f11c97cdaee8de82cfc1947509c033f [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001commit 31b0908a5eff3926195670beecc8548c429ceff5
2Author: Gerard Ryan <G.M0N3Y.2503@gmail.com>
3Date: Sat Oct 31 16:53:39 2020 +1000
4
5 Added support for setting git version externally
6 * This to help when building from source snapshots
7 that don't have the .git file structure.
8
9--- a/CMakeLists.txt
10+++ b/CMakeLists.txt
11@@ -13,27 +13,37 @@ if(MINIMAL)
12 add_definitions(-DTINI_MINIMAL=1)
13 endif()
14
15-# Extract git version and dirty-ness
16-execute_process (
17- COMMAND git --git-dir "${PROJECT_SOURCE_DIR}/.git" --work-tree "${PROJECT_SOURCE_DIR}" log -n 1 --date=local --pretty=format:%h
18- WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
19- RESULT_VARIABLE git_version_check_ret
20- OUTPUT_VARIABLE tini_VERSION_GIT
21-)
22+# Set the git version
23+if (NOT "${TINI_VERSION_GIT}" STREQUAL "")
24+ # Set by the user directly
25+ set(tini_VERSION_GIT "${TINI_VERSION_GIT}")
26+else()
27+ # Extract git version
28+ execute_process (
29+ COMMAND git --git-dir "${PROJECT_SOURCE_DIR}/.git" --work-tree "${PROJECT_SOURCE_DIR}" log -n 1 --date=local --pretty=format:%h
30+ WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
31+ RESULT_VARIABLE git_version_check_ret
32+ OUTPUT_VARIABLE tini_VERSION_GIT
33+ )
34
35-execute_process(
36- COMMAND git --git-dir "${PROJECT_SOURCE_DIR}/.git" --work-tree "${PROJECT_SOURCE_DIR}" status --porcelain --untracked-files=no
37- WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
38- OUTPUT_VARIABLE git_dirty_check_out
39-)
40+ if("${git_version_check_ret}" EQUAL 0)
41+ # Extract git dirty-ness
42+ execute_process(
43+ COMMAND git --git-dir "${PROJECT_SOURCE_DIR}/.git" --work-tree "${PROJECT_SOURCE_DIR}" status --porcelain --untracked-files=no
44+ WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
45+ OUTPUT_VARIABLE git_dirty_check_out
46+ )
47
48-if("${git_version_check_ret}" EQUAL 0)
49- set(tini_VERSION_GIT " - git.${tini_VERSION_GIT}")
50- if(NOT "${git_dirty_check_out}" STREQUAL "")
51- set(tini_VERSION_GIT "${tini_VERSION_GIT}-dirty")
52- endif()
53-else()
54- set(tini_VERSION_GIT "")
55+ if(NOT "${git_dirty_check_out}" STREQUAL "")
56+ set(tini_VERSION_GIT "${tini_VERSION_GIT}-dirty")
57+ endif()
58+ else()
59+ set(tini_VERSION_GIT "")
60+ endif()
61+endif()
62+
63+if(NOT ${tini_VERSION_GIT} STREQUAL "")
64+ set(tini_VERSION_GIT " - git.${tini_VERSION_GIT}")
65 endif()
66
67 # Flags