File tree 1 file changed +27
-10
lines changed 1 file changed +27
-10
lines changed Original file line number Diff line number Diff line change
1
+ set (VERSION_MAJOR 1)
2
+ set (VERSION_MINOR 12)
3
+ set (VERSION_PATCH 0)
4
+ set (VERSION_COMMIT 0)
5
+
1
6
find_program (GIT git)
2
- execute_process (
3
- COMMAND ${GIT} describe
4
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
5
- OUTPUT_VARIABLE GIT_DESCRIBE_DIRTY
6
- OUTPUT_STRIP_TRAILING_WHITESPACE
7
- )
8
- string (REGEX REPLACE "^v([0-9]+)\\ ..*" "\\ 1" VERSION_MAJOR "${GIT_DESCRIBE_DIRTY} " )
9
- string (REGEX REPLACE "^v[0-9]+\\ .([0-9]+).*" "\\ 1" VERSION_MINOR "${GIT_DESCRIBE_DIRTY} " )
10
- string (REGEX REPLACE "^v[0-9]+\\ .[0-9]+\\ .([0-9]+).*" "\\ 1" VERSION_PATCH "${GIT_DESCRIBE_DIRTY} " )
11
- string (REGEX REPLACE "^v[0-9]+\\ .[0-9]+\\ .[0-9]+\\ -([0-9]+).*" "\\ 1" VERSION_COMMIT "${GIT_DESCRIBE_DIRTY} " )
7
+ if (GIT)
8
+ execute_process (
9
+ COMMAND ${GIT} describe
10
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
11
+ OUTPUT_VARIABLE GIT_DESCRIBE_DIRTY
12
+ OUTPUT_STRIP_TRAILING_WHITESPACE
13
+ RESULT_VARIABLE GIT_DESCRIBE_RESULT
14
+ )
15
+
16
+ if (GIT_DESCRIBE_RESULT EQUAL 0)
17
+ string (REGEX REPLACE "^v([0-9]+)\\ ..*" "\\ 1" VERSION_MAJOR "${GIT_DESCRIBE_DIRTY} " )
18
+ string (REGEX REPLACE "^v[0-9]+\\ .([0-9]+).*" "\\ 1" VERSION_MINOR "${GIT_DESCRIBE_DIRTY} " )
19
+ string (REGEX REPLACE "^v[0-9]+\\ .[0-9]+\\ .([0-9]+).*" "\\ 1" VERSION_PATCH "${GIT_DESCRIBE_DIRTY} " )
20
+ string (REGEX REPLACE "^v[0-9]+\\ .[0-9]+\\ .[0-9]+\\ -([0-9]+).*" "\\ 1" VERSION_COMMIT "${GIT_DESCRIBE_DIRTY} " )
21
+ else ()
22
+ message (WARNING "git describe failed with exit code: ${GIT_DESCRIBE_RESULT} " )
23
+ endif ()
24
+ else ()
25
+ message (WARNING "git is not found" )
26
+ endif ()
27
+
28
+ message ("Proceeding with version: ${VERSION_MAJOR} .${VERSION_MINOR} .${VERSION_PATCH} .${VERSION_COMMIT} " )
You can’t perform that action at this time.
0 commit comments