summaryrefslogtreecommitdiff
blob: 99fc5af03787cf442e440ad749cb15e64df4979a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -129,7 +129,14 @@
 	ERROR_QUIET
 )
 ENDIF()
-IF((NOT ${ADD_GIT_INFO}) OR (${PROJECT_VERSION_GIT_RETURN_CODE}))
+# the version.h generation logic is tricky in a number of ways:
+# 1. git describe on a release tarball will always fail with
+#    a non-zero return code, usually 128
+# 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"))
+	MESSAGE(STATUS "Setting fallback Git library version")
 	SET(PROJECT_VERSION_GIT "v${PROJECT_VERSION}")
 ENDIF()
 MESSAGE(STATUS "Setting Git library version to: " ${PROJECT_VERSION_GIT} )