1#-------------------------------------------------------------------------------
2# Copyright (c) 2021-2022, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8execute_process(COMMAND git describe --tags --always
9    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
10    OUTPUT_VARIABLE TFM_VERSION_FULL
11    OUTPUT_STRIP_TRAILING_WHITESPACE)
12
13string(REGEX REPLACE "TF-M" "" TFM_VERSION_FULL ${TFM_VERSION_FULL})
14# remove a commit number
15string(REGEX REPLACE "-[0-9]+-g" "+" TFM_VERSION_FULL ${TFM_VERSION_FULL})
16string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" TFM_VERSION ${TFM_VERSION_FULL})
17