blob: 3090b658e221f1cfc916e8972ec173c817f9a355 [file] [log] [blame] [edit]
From d30dae3926471086b32473e56b4092275e2ceac9 Mon Sep 17 00:00:00 2001
From: David Aguilar <davvid@gmail.com>
Date: Mon, 20 May 2019 13:02:47 -0700
Subject: [PATCH] cmake: add a fallback version when git is unavailable
Closes #41
Signed-off-by: David Aguilar <davvid@gmail.com>
---
CMakeLists.txt | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c708153..f2346a0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,12 +37,16 @@ if (NOT DEFINED PTEX_VER)
file(STRINGS "${PROJECT_SOURCE_DIR}/version" PTEX_VER)
else ()
execute_process(
- COMMAND git describe --first-parent --always HEAD
+ COMMAND git describe --match=v[0-9]*.[0-9]* --first-parent HEAD
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE PTEX_VER
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif ()
endif ()
+# Provide a fallback version when the Git repository is unavailable.
+if (NOT PTEX_VER)
+ set(PTEX_VER "v2.3.X")
+endif()
# Transform PTEX_VER into PTEX_MAJOR_VERSION and PTEX_MINOR_VERSION
string(REPLACE "v" "" PTEX_VER_STRIPPED ${PTEX_VER}) # strip leading "v"