Build: Unify TF-M version setting
In each release, two TF-M version settings, one in CMake and the other
one in tfm_version.h, shall be both updated. Either one may be missed in
release.
This commit unifies TF-M version settings. Only the version in root
CMakeLists.txt shall be updated. The version used in source code will be
automatically updated during build.
Change-Id: I2709a6cb81d2be813bb0921ca811a0d899f97f53
Signed-off-by: David Hu <david.hu@arm.com>
diff --git a/secure_fw/spm/CMakeLists.txt b/secure_fw/spm/CMakeLists.txt
index a9188ed..7ce15e3 100755
--- a/secure_fw/spm/CMakeLists.txt
+++ b/secure_fw/spm/CMakeLists.txt
@@ -14,6 +14,10 @@
set(TFM_PARTITION_PLATFORM ON CACHE BOOL "Enable the TF-M Platform partition")
+# Generate TF-M version
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/tfm_version.h.in
+ ${CMAKE_BINARY_DIR}/generated/secure_fw/spm/include/tfm_version.h)
+
target_include_directories(tfm_spm
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
@@ -26,6 +30,7 @@
${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/secure_fw/include
${CMAKE_BINARY_DIR}/generated
+ ${CMAKE_BINARY_DIR}/generated/secure_fw/spm/include
$<$<BOOL:${TFM_PSA_API}>:${CMAKE_BINARY_DIR}/generated/secure_fw/spm/cmsis_psa>
$<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_BINARY_DIR}/generated/secure_fw/spm/cmsis_func>
)
diff --git a/secure_fw/spm/include/tfm_version.h b/secure_fw/spm/include/tfm_version.h
deleted file mode 100644
index 7a0e69e..0000000
--- a/secure_fw/spm/include/tfm_version.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-#ifndef __TFM_VERSION_H__
-#define __TFM_VERSION_H__
-
-/*
- * Defines for TFM version.
- */
-#define VERSION_MAJOR 1
-#define VERSION_MINOR 4
-#define VERSION_HOTFIX 0
-#define VERSION_STRING ""
-
-#define VERSTR(x) #x
-#define VERCON(major, minor, hotfix) VERSTR(major)"."VERSTR(minor)"."VERSTR(hotfix)
-
-#define VERSION_FULLSTR VERCON(VERSION_MAJOR, VERSION_MINOR, VERSION_HOTFIX)""VERSION_STRING
-
-
-
-#endif /* __TFM_VERSION_H__ */
diff --git a/secure_fw/spm/include/tfm_version.h.in b/secure_fw/spm/include/tfm_version.h.in
new file mode 100644
index 0000000..fa815f7
--- /dev/null
+++ b/secure_fw/spm/include/tfm_version.h.in
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef __TFM_VERSION_H__
+#define __TFM_VERSION_H__
+
+/*
+ * Defines for TFM version.
+ */
+#cmakedefine TFM_VERSION @TFM_VERSION@
+
+#define VERSION_STRING ""
+
+#define VERSTR(x) #x
+#define VERCON(x) VERSTR(x)
+
+#define VERSION_FULLSTR VERCON(TFM_VERSION)""VERSION_STRING
+
+#endif /* __TFM_VERSION_H__ */