From: Jakob Haufe <sur5r@debian.org>
Date: Sun, 13 Oct 2024 15:52:10 +0200
Subject: Use debian changelog date as commit date

Forwarded: not-needed
Last-Update: 2024-09-23

Upstream embeds the latest commit date in the version string.
This patch uses the latest d/changelog entry instead to make the build
reproducible.
---
 CMakeLists.txt | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1ca6b30..db31630 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -57,6 +57,18 @@ if (NOT ${COMMIT_DATE_VALID} STREQUAL "0")
   string (TIMESTAMP COMMIT_DATE %Y-%m-%d)
 endif ()
 
+execute_process(
+	COMMAND dpkg-parsechangelog -l ../debian/changelog -S Date
+	COMMAND date --utc -f /dev/stdin +%Y-%m-%d
+	RESULT_VARIABLE DCH_DATE_VALID
+	OUTPUT_VARIABLE DCH_DATE
+	OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+if (${DCH_DATE_VALID} STREQUAL "0")
+	message (STATUS "debian/changelog found, using entry date as commit date: ${DCH_DATE}")
+	set (COMMIT_DATE "${DCH_DATE}")
+endif ()
+
 # Uncomment for snapshots, comment for releases
 set(VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}-${BRANCH}${COMMIT_COUNT}")
 
