File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,8 +39,21 @@ endfunction()
3939if (GIT_VERSION AND NOT ${GIT_INFO} STREQUAL "")
4040 message("-- Using Git to calculate AWS IoT Device Client version information...")
4141
42- # Get last tag from git - this only matches tags starting with v, so we ignore non-versioning tags
43- execute_process(COMMAND ${GIT_EXECUTABLE} describe --abbrev=0 --tags --match "v[0-9]*"
42+ # Get first tag with major and minor of the latest tag.
43+ execute_process(
44+ COMMAND bash -c "
45+ read LATEST_MAJOR_VERSION LATEST_MINOR_VERSION < <(git describe --abbrev=0 --tags | awk -F. '
46+ {
47+ gsub(/^v/, \"\", \$0)
48+
49+ split(\$0, parts, \".\")
50+ LATEST_MAJOR_VERSION = parts[1]
51+ LATEST_MINOR_VERSION = parts[2]
52+ print LATEST_MAJOR_VERSION, LATEST_MINOR_VERSION
53+
54+ }')
55+ git tag --sort=creatordate | grep -E \"^v?\${LATEST_MAJOR_VERSION}\.\${LATEST_MINOR_VERSION}(\\.\[0-9]+)?\" | head -n 1
56+ "
4457 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
4558 OUTPUT_VARIABLE ${PROJECT_NAME}_VERSION_STRING
4659 OUTPUT_STRIP_TRAILING_WHITESPACE
You can’t perform that action at this time.
0 commit comments