1From feb5d9c6b7bcec788f9b01781c205e31fff260e7 Mon Sep 17 00:00:00 2001
2From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
3Date: Tue, 11 Aug 2020 23:07:08 +0200
4Subject: [PATCH] cmake/Modules/Version.cmake: don't use Git version if not in
5 a Git repo
6
7If the librtlsdr code comes from a tarball, it doesn't have any .git/
8metadata, and therefore even if Git (as a tool) is found, the logic in
9cmake/Modules/Version.cmake fails finding a version through Git:
10
11-- Extracting version information from git describe...
12fatal: Not a git repository (or any of the parent directories): .git
13
14As a consequence, the VERSION variable is empty, which later causes
15cmake to bail out with:
16
17CMake Error at /home/test/autobuild/run/instance-1/output-1/host/share/cmake-3.15/Modules/WriteBasicConfigVersionFile.cmake:43 (message):
18  No VERSION specified for WRITE_BASIC_CONFIG_VERSION_FILE()
19Call Stack (most recent call first):
20  /home/test/autobuild/run/instance-1/output-1/host/share/cmake-3.15/Modules/CMakePackageConfigHelpers.cmake:225 (write_basic_config_version_file)
21  CMakeLists.txt:173 (write_basic_package_version_file)
22
23To avoid this, we only use Git to determine the version if the cmake
24project top-level source directory has a .git/ folder.
25
26Upstream: https://github.com/librtlsdr/librtlsdr/pull/75
27Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
28---
29 cmake/Modules/Version.cmake | 2 +-
30 1 file changed, 1 insertion(+), 1 deletion(-)
31
32diff --git a/cmake/Modules/Version.cmake b/cmake/Modules/Version.cmake
33index 2d4e76d..6f67fa4 100644
34--- a/cmake/Modules/Version.cmake
35+++ b/cmake/Modules/Version.cmake
36@@ -32,7 +32,7 @@ set(PATCH_VERSION ${VERSION_INFO_PATCH_VERSION})
37 ########################################################################
38 find_package(Git QUIET)
39
40-if(GIT_FOUND)
41+if(GIT_FOUND AND EXISTS ${CMAKE_SOURCE_DIR}/.git)
42     message(STATUS "Extracting version information from git describe...")
43     execute_process(
44         COMMAND ${GIT_EXECUTABLE} describe --always --abbrev=4 --long
45--
462.26.2
47
48