blob: 8debfe94ffe853cd2868bc2f35739937a1a0dae6 (
plain)
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
47
48
49
50
51
|
From 2ca80486ba6a4e5acbdf0ff581d9754af17fa33b Mon Sep 17 00:00:00 2001
From: baranyaib90 <5031516+baranyaib90@users.noreply.github.com>
Date: Mon, 24 Oct 2022 22:53:37 +0200
Subject: [PATCH] Allow external setting of GIT_VERSION
---
CMakeLists.txt | 34 ++++++++++++++++++----------------
1 file changed, 18 insertions(+), 16 deletions(-)
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -36,22 +36,24 @@ endif()
# VERSION
-find_package(Git)
-if(Git_FOUND)
- execute_process(
- COMMAND "${GIT_EXECUTABLE}" show --date=format:%Y.%m.%d --format=%ad-%h --no-patch
- WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
- OUTPUT_VARIABLE GIT_VERSION
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- message(STATUS "Version: ${GIT_VERSION}")
+if(NOT GIT_VERSION)
+ find_package(Git)
+ if(Git_FOUND)
+ execute_process(
+ COMMAND "${GIT_EXECUTABLE}" show --date=format:%Y.%m.%d --format=%ad-%h --no-patch
+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
+ OUTPUT_VARIABLE GIT_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ message(STATUS "Version: ${GIT_VERSION}")
- # May not update version in some cases (example: git commit --amend)
- set_property(GLOBAL APPEND
- PROPERTY CMAKE_CONFIGURE_DEPENDS
- "${CMAKE_SOURCE_DIR}/.git/index")
-else()
- set(GIT_VERSION "UNKNOWN")
- message(WARNING "Could not find git command! Version is set to: ${GIT_VERSION}")
+ # May not update version in some cases (example: git commit --amend)
+ set_property(GLOBAL APPEND
+ PROPERTY CMAKE_CONFIGURE_DEPENDS
+ "${CMAKE_SOURCE_DIR}/.git/index")
+ else()
+ set(GIT_VERSION "UNKNOWN")
+ message(WARNING "Could not find git command! Version is set to: ${GIT_VERSION}")
+ endif()
endif()
# LIBRARY DEPENDENCIES
|