File: 05_re-work-version-detection.patch

package info (click to toggle)
kcov 43%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,684 kB
  • sloc: cpp: 12,619; ansic: 2,379; python: 2,000; sh: 333; makefile: 140; javascript: 65; xml: 7; asm: 4
file content (63 lines) | stat: -rw-r--r-- 2,132 bytes parent folder | download | duplicates (3)
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
52
53
54
55
56
57
58
59
60
61
62
63
From: William Desportes <williamdes@wdes.fr>
Date: Mon, 15 Jul 2024 20:35:05 +0200
Subject: Patch the version command in build steps

Origin: vendor
Forwarded: not-needed
---
 CMakeLists.txt | 41 ++++++-----------------------------------
 1 file changed, 6 insertions(+), 35 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ee73827..5061170 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,42 +1,13 @@
 cmake_minimum_required (VERSION 3.12)
 project (kcov)
 
+execute_process (COMMAND dpkg-parsechangelog -SVersion -l${CMAKE_SOURCE_DIR}/debian/changelog
+    OUTPUT_VARIABLE POD_VERSION
+    OUTPUT_STRIP_TRAILING_WHITESPACE
+)
 
-# See https://eatmyrandom.blogspot.com/2010/06/automate-version-numbering-using-git.html
-if (EXISTS "${CMAKE_SOURCE_DIR}/.git")
-    find_program (GIT_EXECUTABLE NAMES git)
-    if (GIT_EXECUTABLE)
-        message (STATUS "Found Git: ${GIT_EXECUTABLE}")
-    else (GIT_EXECUTABLE)
-        message (FATAL_ERROR "Could NOT find Git")
-    endif (GIT_EXECUTABLE)
-
-    execute_process (COMMAND "${GIT_EXECUTABLE}"
-            "--git-dir=${CMAKE_SOURCE_DIR}/.git"
-            describe
-            --abbrev=4
-            --tags
-            HEAD
-        OUTPUT_VARIABLE POD_VERSION
-        OUTPUT_STRIP_TRAILING_WHITESPACE
-    )
-
-    message (STATUS "kcov version: ${POD_VERSION}")
-else (EXISTS "${CMAKE_SOURCE_DIR}/.git")
-    execute_process (COMMAND head
-            -n 1
-            "${CMAKE_SOURCE_DIR}/ChangeLog"
-        COMMAND cut -d \( -f 2
-        COMMAND cut -d \) -f 1
-        OUTPUT_VARIABLE POD_VERSION
-        OUTPUT_STRIP_TRAILING_WHITESPACE
-    )
-
-    message (STATUS "kcov version: ${POD_VERSION} (from changelog)")
-endif (EXISTS "${CMAKE_SOURCE_DIR}/.git")
-
-# Example POD_VERSION format: v42-148-g29ae1
-string(REGEX REPLACE "v([0-9]+).*" "\\1" PROJECT_VERSION_MAJOR ${POD_VERSION})
+# Example POD_VERSION format: v42-148-g29ae1 or 43+dfsg-1
+string(REGEX REPLACE "v?([0-9]+).*" "\\1" PROJECT_VERSION_MAJOR ${POD_VERSION})
 
 # Set the PROJECT_VERSION_MAJOR with the extracted version
 set (PROJECT_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})