Debian Codegraph @

build_files/platforms/msys2/UpdateInfo.cmake

raw
1 # cmakefile executed within a makefile target
2
3 # we look for the git command in this paths by order of preference
4 find_program(GIT_CMD git.exe HINTS ENV Path PATH_SUFFIXES ../)
5
6 # Fail if Git is not installed
7 if (GIT_CMD STREQUAL GIT_CMD-NOTFOUND)
8 message(FATAL_ERROR "git command not found!")
9 else ()
10 message(STATUS "git command found: ${GIT_CMD}")
11 endif ()
12
13 # Get version description.
14 # Depending on whether you checked out a branch (dev) or a tag (release),
15 # "git describe" will return "5.0-gtk2-2-g12345678" or "5.0-gtk2", respectively.
16 execute_process(COMMAND ${GIT_CMD} describe --tags --always OUTPUT_VARIABLE GIT_DESCRIBE OUTPUT_STRIP_TRAILING_WHITESPACE WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}")
17
18 # Get branch name.
19 # Will return empty if you checked out a commit or tag. Empty string handled later.
20 execute_process(COMMAND ${GIT_CMD} symbolic-ref --short -q HEAD OUTPUT_VARIABLE GIT_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}")
21
22 # Get commit hash.
23 execute_process(COMMAND ${GIT_CMD} rev-parse --short --verify HEAD OUTPUT_VARIABLE GIT_COMMIT OUTPUT_STRIP_TRAILING_WHITESPACE WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}")
24
25 # Get commit date, YYYY-MM-DD.
26 execute_process(COMMAND ${GIT_CMD} show -s --format=%cd --date=format:%Y-%m-%d OUTPUT_VARIABLE GIT_COMMIT_DATE OUTPUT_STRIP_TRAILING_WHITESPACE WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}")
27
28 # Get number of commits since tagging. This is what "GIT_DESCRIBE" uses.
29 # Works when checking out branch, tag or commit.
30 # Get a list of all tags in repo:
31 execute_process(COMMAND ${GIT_CMD} tag --merged HEAD OUTPUT_VARIABLE GIT_TAG WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}")
32 # Replace newlines with semicolons so that it can be split:
33 string(REPLACE "\n" ";" GIT_TAG_LIST "${GIT_TAG}")
34 execute_process(COMMAND ${GIT_CMD} rev-list --count HEAD --not ${GIT_TAG_LIST} OUTPUT_VARIABLE GIT_COMMITS_SINCE_TAG OUTPUT_STRIP_TRAILING_WHITESPACE WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}")
35
36 # Numeric version only. Use it only if you have no choice, because it doesn't tell the branch or commit since tag
37 #execute_process(COMMAND ${GIT_CMD} describe --tags --always --abbrev=0 OUTPUT_VARIABLE GIT_DESCRIBE_NUMERIC OUTPUT_STRIP_TRAILING_WHITESPACE WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}")
38 #string(REGEX REPLACE "-.*" "" GIT_DESCRIBE_NUMERIC ${GIT_DESCRIBE_NUMERIC})
39 set(GIT_NUMERIC_VERSION_ONLY "${LHDR_VERSION_MAJOR}.${LHDR_VERSION_MINOR}.${LHDR_VERSION_PATCH}")
40
41 # Get number of commits since branching.
42 # Works when checking out branch, tag or commit.
43 execute_process(COMMAND ${GIT_CMD} rev-list --count HEAD --not --tags OUTPUT_VARIABLE GIT_COMMITS_SINCE_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}")
44
45 # If user checked-out something which is not a branch, use the description as branch name.
46 if (GIT_BRANCH STREQUAL "")
47 set (GIT_BRANCH "${GIT_DESCRIBE}")
48 endif()
49
50 # Create numeric version.
51 # This version is nonsense, either don't use it at all or use it only where you have no other choice, e.g. Inno Setup's VersionInfoVersion.
52 # Strip everything after hyphen, e.g. "5.0-gtk2" -> "5.0", "5.1-rc1" -> "5.1" (ergo BS).
53 if (GIT_COMMITS_SINCE_TAG STREQUAL "")
54 set (GIT_NUMERIC_VERSION_BS "0.0.0")
55 else ()
56 string(REGEX REPLACE "-.*" "" GIT_NUMERIC_VERSION_BS ${GIT_DESCRIBE})
57 set(GIT_NUMERIC_VERSION_BS "${GIT_NUMERIC_VERSION_BS}.${GIT_COMMITS_SINCE_TAG}")
58 endif ()
59
60 message(STATUS "Git checkout information:")
61 message(STATUS " Commit description: ${GIT_DESCRIBE}")
62 message(STATUS " Branch: ${GIT_BRANCH}")
63 message(STATUS " Commit: ${GIT_COMMIT}")
64 message(STATUS " Commit date: ${GIT_COMMIT_DATE}")
65 message(STATUS " Commits since tag: ${GIT_COMMITS_SINCE_TAG}")
66 message(STATUS " Commits since branch: ${GIT_COMMITS_SINCE_BRANCH}")
67 message(STATUS " Version: ${GIT_NUMERIC_VERSION_BS} (unreliable)")
68 message(STATUS " Numeric Version: ${GIT_NUMERIC_VERSION_ONLY} (unreliable)")
69
70 if (BIT_DEPTH EQUAL 4)
71 set(BUILD_BIT_DEPTH 32)
72 # 32 bits builds has to be installable on 64 bits system, to support WinXP/64.
73 set(ARCHITECTURE_ALLOWED "x86 x64 ia64")
74 # installing in 32 bits mode even on 64 bits OS and architecture
75 set(INSTALL_MODE "")
76 elseif (BIT_DEPTH EQUAL 8)
77 set(BUILD_BIT_DEPTH 64)
78 # Restricting the 64 bits builds to 64 bits systems only
79 set(ARCHITECTURE_ALLOWED "x64 ia64")
80 # installing in 64 bits mode for all 64 bits processors, even for itanium architecture
81 set(INSTALL_MODE "x64 ia64")
82 endif (BIT_DEPTH EQUAL 4)
83 # set part of the output archive name
84 set(SYSTEM_NAME "WinVista")
85
86 configure_file ("${PROJECT_SOURCE_DIR}/build_files/platforms/msys2/WindowsInnoSetup.iss.in" "${CMAKE_INSTALL_PREFIX}/WindowsInnoSetup.iss")