Build: Reorganize BL2 configuration in cmake
This commit moves the BL2 related configuration switches from the
CommonConfig.cmake file to a separate MCUBootConfig.cmake file to
make its maintenance easier.
Change-Id: I3869528bdbd2a5a071f3b3cc4b2782d22114b1ca
Signed-off-by: David Vincze <david.vincze@arm.com>
diff --git a/cmake/Common/BuildSys.cmake b/cmake/Common/BuildSys.cmake
index 4de9f3b..396e131 100644
--- a/cmake/Common/BuildSys.cmake
+++ b/cmake/Common/BuildSys.cmake
@@ -159,6 +159,37 @@
endif()
endfunction()
+#Check the value of a cache variable whether it is valid.
+#
+# This function currently only supports 'STRING' type variables and uses
+# the 'STRINGS' cache entry property as the validation list.
+#
+#Examples:
+# validate_cache_value(MCUBOOT_SIGNATURE_TYPE)
+#
+#INPUTS:
+# variable_name - (mandatory) - Name of the cache variable to be checked.
+#
+#OUTPUTS:
+# n/a
+#
+function(validate_cache_value variable_name)
+ #Check if the type of the variable is STRING.
+ get_property(_type CACHE ${variable_name} PROPERTY TYPE)
+ if(NOT ${_type} STREQUAL "STRING")
+ message(FATAL_ERROR "validate_cache_value: type of CACHE variable must be 'STRING', the type of '${variable_name}' variable is '${_type}'.")
+ endif()
+ get_property(_validation_list CACHE ${variable_name} PROPERTY STRINGS)
+ #Check if validation list is set.
+ if (NOT _validation_list)
+ message(FATAL_ERROR "validate_cache_value: CACHE variable '${variable_name}' has no 'STRINGS' validation list set.")
+ endif()
+ #See if the value of the variable is in the list.
+ if (NOT ${${variable_name}} IN_LIST _validation_list)
+ message(FATAL_ERROR "validate_cache_value: variable value '${${variable_name}}' of variable '${variable_name}' is not matching the validation list ${_validation_list}.")
+ endif()
+endfunction()
+
#Specify an include path for the compiler
#
# Specify a global include directory for all non external targets in the current