-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinfo.cmake
34 lines (28 loc) · 1.05 KB
/
info.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
if(NOT INFO_GIT_DIR)
set(INFO_GIT_DIR ${PROJECT_SOURCE_DIR})
endif()
set(GIT_EXECUTABLE git)
set(DATE_EXECUTABLE date)
cmake_host_system_information(RESULT HOSTNAME QUERY HOSTNAME)
set(USERNAME $ENV{USERNAME})
set(BUILD_USER "${USERNAME}@${HOSTNAME}")
execute_process(
COMMAND "${DATE_EXECUTABLE}" "+%Y-%m-%d %H:%M:%S %z"
OUTPUT_VARIABLE BUILD_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
execute_process(
COMMAND "${DATE_EXECUTABLE}" "+%s"
OUTPUT_VARIABLE BUILD_TIME
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
execute_process(
COMMAND "${GIT_EXECUTABLE}" describe --always --dirty --broken
--match=:NoMatchGivesMeTheHash: --abbrev=0
WORKING_DIRECTORY "${INFO_GIT_DIR}"
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
execute_process(
COMMAND "${GIT_EXECUTABLE}" describe --tags --always --dirty --broken
WORKING_DIRECTORY "${INFO_GIT_DIR}"
OUTPUT_VARIABLE GIT_COMMIT_DESCRIBE
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
configure_file("${PROJECT_SOURCE_DIR}/src/info.c.in" src/info.c)