@@ -125,13 +125,23 @@ endmacro()
125125# Save the version with a timestamp to a cache variable
126126
127127function (_cgv_store_version vstring vsuffix vhash tsfile)
128+ if (NOT vstring)
129+ set (vstring "${${CGV_PROJECT} _VERSION}" )
130+ if (vstring)
131+ string (REPLACE "${vstring} " "" vsuffix "${${CGV_PROJECT} _VERSION_STRING}" )
132+ message (VERBOSE "Using fallback version and string: "
133+ "${CGV_PROJECT} _VERSION=${vstring} , "
134+ "${CGV_PROJECT} _VERSION_STRING=${${CGV_PROJECT} _VERSION_STRING}"
135+ )
136+ endif ()
137+ endif ()
128138 if (NOT vstring)
129139 message (WARNING "The version metadata for ${CGV_PROJECT} could not "
130140 "be determined: installed version number may be incorrect. Try "
131141 "downloading an official release tarball, using `git archive`, "
132142 "using `git clone` without `--shallow` nor deleting `.git`, or "
133143 "manually specifying a known version by configuring with "
134- "`-D${CGV_PROJECT} _VERSION=1.2.3" )
144+ "`-D${CGV_PROJECT} _VERSION=1.2.3` " )
135145 endif ()
136146 # Replace 11-03 with 11.3
137147 string (REGEX REPLACE "-+0*" "." vstring "${vstring} " )
@@ -197,23 +207,23 @@ function(_cgv_try_parse_git_describe version_string branch_string tsfile)
197207
198208 if (CMAKE_MATCH_2)
199209 # After a pre-release, e.g. -rc.1, for SemVer compatibility
200- set (_prerelease "${CMAKE_MATCH_2} .${CMAKE_MATCH_4} " )
210+ set (_suffix "${CMAKE_MATCH_2} .${CMAKE_MATCH_4} " )
201211 else ()
202212 # After a release, e.g. -123
203- set (_prerelease "-${CMAKE_MATCH_4} " )
213+ set (_suffix "-${CMAKE_MATCH_4} " )
204214 endif ()
205215
206216 if (branch_string)
207- set (_suffix "${branch_string} .${CMAKE_MATCH_5} " )
217+ set (_hash "${branch_string} .${CMAKE_MATCH_5} " )
208218 else ()
209- set (_suffix "${CMAKE_MATCH_5} " )
219+ set (_hash "${CMAKE_MATCH_5} " )
210220 endif ()
211221
212222 # Qualify the version number with the distance-to-tag and hash
213223 _cgv_store_version(
214224 "${CMAKE_MATCH_1} " # 1.2.3
215- "${_prerelease } " # -rc.2.3, -beta.1, -123
216- "${_suffix } " # abcdef
225+ "${_suffix } " # -rc.2.3, -beta.1, -123
226+ "${_hash } " # abcdef
217227 "${tsfile} " # timestamp file
218228 )
219229endfunction ()
@@ -291,7 +301,7 @@ function(_cgv_try_git_describe)
291301 # Load git description
292302 _cgv_git_call_output(_VERSION_STRING "describe" "--tags" ${_match} )
293303 if (_VERSION_STRING_RESULT)
294- message (AUTHOR_WARNING "No suitable git tags found ': ${_VERSION_STRING_ERR} " )
304+ message (AUTHOR_WARNING "No git tags match ' ${CGV_TAG_REGEX} ': ${_VERSION_STRING_ERR} " )
295305 return ()
296306 endif ()
297307 if (_VERSION_STRING_ERR)
@@ -333,17 +343,13 @@ endfunction()
333343#-----------------------------------------------------------------------------#
334344
335345function (_cgv_try_cmake)
336- set (_ver "${${CGV_PROJECT} _VERSION}" )
337- if (NOT _ver)
346+ if (NOT DEFINED "${${CGV_PROJECT} _VERSION}" )
338347 message (AUTHOR_WARNING
339- "No fallback version specified from ${CGV_PROJECT} _VERSION"
340- )
348+ "No fallback version specified from ${CGV_PROJECT} _VERSION" )
341349 return ()
342350 endif ()
343351
344- string (REPLACE "${_ver} " "" _suffix "${${CGV_PROJECT} _VERSION_STRING}" )
345-
346- _cgv_store_version("${${CGV_PROJECT} _VERSION}" "${_suffix} " "" "${CMAKE_PARENT_LIST_FILE} " )
352+ _cgv_store_version("" "" "" "${CMAKE_PARENT_LIST_FILE} " )
347353endfunction ()
348354
349355#-----------------------------------------------------------------------------#
0 commit comments