1#------------------------------------------------------------------------------- 2# Copyright (c) 2021-2022, Arm Limited. All rights reserved. 3# 4# SPDX-License-Identifier: BSD-3-Clause 5# 6#------------------------------------------------------------------------------- 7 8# The 'TFM_VERSION_MANUAL' is used for fallback when Git tags are not available 9set(TFM_VERSION_MANUAL "1.8.0") 10 11execute_process(COMMAND git describe --tags --always 12 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 13 OUTPUT_VARIABLE TFM_VERSION_FULL 14 OUTPUT_STRIP_TRAILING_WHITESPACE) 15 16# In a repository cloned with --no-tags option TFM_VERSION_FULL will be a hash 17# only hence checking it for a tag format to accept as valid version. 18 19string(FIND ${TFM_VERSION_FULL} "TF-M" TFM_TAG) 20if(TFM_TAG EQUAL -1) 21 set(TFM_VERSION_FULL v${TFM_VERSION_MANUAL}) 22 message(WARNING "Actual TF-M version is not available from Git repository. Settled to " ${TFM_VERSION_FULL}) 23endif() 24 25string(REGEX REPLACE "TF-M" "" TFM_VERSION_FULL ${TFM_VERSION_FULL}) 26# remove a commit number 27string(REGEX REPLACE "-[0-9]+-g" "+" TFM_VERSION_FULL ${TFM_VERSION_FULL}) 28string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" TFM_VERSION ${TFM_VERSION_FULL}) 29 30# Check that manually set version is up to date 31if (NOT TFM_VERSION_MANUAL STREQUAL TFM_VERSION) 32 message(WARNING "TFM_VERSION_MANUAL mismatches to actual TF-M version. Please update TFM_VERSION_MANUAL in cmake/version.cmake") 33endif() 34