Skip to content
Snippets Groups Projects
Commit 1fe36af4 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit Committed by Kitware Robot
Browse files

Merge topic 'fix-determine-version'


cf91ca52 Fix issues with VTKmDetermineVersion.

Acked-by: default avatarKitware Robot <kwrobot@kitware.com>
Acked-by: default avatarRobert Maynard <robert.maynard@kitware.com>
Merge-request: !1166
parents 6d0e3036 cf91ca52
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -41,21 +41,27 @@ function(determine_version source_dir git_command var_prefix)
# information. Just return here to avoid the warning message at the end of
# this function.
return ()
elseif (NOT VTKm_GIT_DESCRIBE)
if(EXISTS ${git_command} AND EXISTS ${source_dir}/.git)
execute_process(
COMMAND ${git_command} describe
WORKING_DIRECTORY ${source_dir}
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE)
elseif (NOT VTKm_GIT_DESCRIBE AND
EXISTS ${git_command} AND
EXISTS ${source_dir}/.git)
execute_process(
COMMAND ${git_command} describe
WORKING_DIRECTORY ${source_dir}
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE)
if (NOT result EQUAL 0)
# git describe failed (bad return code).
set(output "")
endif()
else()
set(result 0)
set(output ${VTKm_GIT_DESCRIBE})
else ()
# note, output may be set to empty if VTKm_GIT_DESCRIBE is not defined.
set(output "${VTKm_GIT_DESCRIBE}")
endif()
unset(tmp_VERSION)
extract_version_components("${output}" tmp)
if(DEFINED tmp_VERSION)
if (NOT "${tmp_VERSION}" STREQUAL "${${var_prefix}_VERSION}")
......@@ -74,14 +80,16 @@ endfunction()
# Extracts components from a version string. See determine_version() for usage.
function(extract_version_components version_string var_prefix)
string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)[-]*(.*)"
string(REGEX MATCH "^v?(([0-9]+)\\.([0-9]+)\\.([0-9]+)-?(.*))$"
version_matches "${version_string}")
if(CMAKE_MATCH_0)
set(full ${CMAKE_MATCH_0})
set(major ${CMAKE_MATCH_1})
set(minor ${CMAKE_MATCH_2})
set(patch ${CMAKE_MATCH_3})
set(patch_extra ${CMAKE_MATCH_4})
# note, we don't use CMAKE_MATCH_0 for `full` since it may or may not have
# the `v` prefix.
set(full ${CMAKE_MATCH_1})
set(major ${CMAKE_MATCH_2})
set(minor ${CMAKE_MATCH_3})
set(patch ${CMAKE_MATCH_4})
set(patch_extra ${CMAKE_MATCH_5})
set(${var_prefix}_VERSION "${major}.${minor}" PARENT_SCOPE)
set(${var_prefix}_VERSION_MAJOR ${major} PARENT_SCOPE)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment