Nitrokey / libnitrokey

Communicate with Nitrokey devices in a clean and easy manner
https://nitrokey.com/
GNU Lesser General Public License v3.0
65 stars 34 forks source link

Wrong project version #220

Open panicgh opened 1 year ago

panicgh commented 1 year ago

Building libnitrokey with -DADD_GIT_INFO=OFF causes it to fallback to the project version specified in the CMakeLists.txt. Apparently this version was not incremented for the 3.8 release and later, i.e. it is still displayed as version 3.7.0 in nitrokey-app, some log output etc.

https://github.com/Nitrokey/libnitrokey/blob/9fbaaa9f4576de43e892c475ce18f66791b62a43/CMakeLists.txt#L24

szszszsz commented 1 year ago

Good spot! This certainly should be corrected for the next release. FWIW there are no implementation differences between 3.8 and 3.7 AFAIR.

jjakob commented 1 year ago

I also patch it to allow setting PROJECT_VERSION_GIT as cmake cache variable from CLI, '-DPROJECT_VERSION_GIT="v3.8-10-ge4b2b91' as I build from a source snapshot with no git available during build. This patch doesn't change any behavior if PROJECT_VERSION_GIT is not set in cache so I think it could be applied upstream.

From 3d58ea51b9922d529c6402c5cd10849c0b8f6ba3 Mon Sep 17 00:00:00 2001
From: Jernej Jakob <jernej.jakob@gmail.com>
Date: Sun, 14 May 2023 23:52:11 +0200
Subject: [PATCH 1/2] CMakeLists.txt: allow setting PROJECT_VERSION_GIT from
 CLI

---
 CMakeLists.txt | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 246923d..b604b8a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -142,7 +142,10 @@ ENDIF()
 # 2. If git is not installed, PROJECT_VERSION_GIT_RETURN_CODE
 #    will contain the string 'No such file or directory'
 # Hence fallback to PROJECT_VERSION when the return code is NOT 0.
-IF((NOT ${ADD_GIT_INFO}) OR (NOT ${PROJECT_VERSION_GIT_RETURN_CODE} STREQUAL "0"))
+IF(((NOT ${ADD_GIT_INFO})
+               OR (NOT ${PROJECT_VERSION_GIT_RETURN_CODE} STREQUAL "0")
+               )
+               AND (NOT PROJECT_VERSION_GIT))
        MESSAGE(STATUS "Setting fallback Git library version")
        SET(PROJECT_VERSION_GIT "v${PROJECT_VERSION}")
 ENDIF()
--
2.39.3