forked from utwente-fmt/dftcalc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcompiletime.cmake
46 lines (44 loc) · 1.17 KB
/
compiletime.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
35
36
37
38
39
40
41
42
43
44
45
46
execute_process(
COMMAND date "+%Y-%m-%d %H:%M:%S"
OUTPUT_VARIABLE date_output OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(USECOMMANDLINEGITINFO STREQUAL "YES")
else()
execute_process(
COMMAND git rev-parse --verify HEAD
OUTPUT_VARIABLE git_output OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND git describe HEAD
OUTPUT_VARIABLE git_descr OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND git diff --exit-code
OUTPUT_QUIET
ERROR_QUIET
RESULT_VARIABLE git_changed
)
set(git_version "*.*.*")
execute_process(
COMMAND git describe --tags --match=v[0-9]* --abbrev=0
OUTPUT_VARIABLE git_version OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND git branch
OUTPUT_VARIABLE git_test OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
if (git_version STREQUAL git_descr)
else()
set(git_version ${git_version}+)
endif()
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/compiletime.h
"/**
* Generated at compile time on ${date_output}
*/
#define DFT2LNTROOT \"${DFTROOT}\"
#define COMPILETIME_DATE \"${date_output}\"
#define COMPILETIME_GITREV \"${git_output}\"
#define COMPILETIME_GITCHANGED ${git_changed}
#define COMPILETIME_GITVERSION \"${git_version}\"
")