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/CommonConfig.cmake b/CommonConfig.cmake
index ee2faee..a1cd01d 100644
--- a/CommonConfig.cmake
+++ b/CommonConfig.cmake
@@ -30,15 +30,7 @@
 endif()
 
 #BL2 bootloader (MCUBoot) related settings
-if(NOT DEFINED BL2)
-	set(BL2 True CACHE BOOL "Configure TF-M to use BL2 and enable building BL2")
-endif()
-if (BL2)
-	if (NOT DEFINED MCUBOOT_UPGRADE_STRATEGY)
-		set (MCUBOOT_UPGRADE_STRATEGY "OVERWRITE_ONLY" CACHE STRING "Configure BL2 which upgrade strategy to use")
-		set_property(CACHE MCUBOOT_UPGRADE_STRATEGY PROPERTY STRINGS "OVERWRITE_ONLY;SWAP;NO_SWAP;RAM_LOADING")
-	endif()
-endif()
+include(${CMAKE_CURRENT_LIST_DIR}/bl2/ext/mcuboot/MCUBootConfig.cmake)
 
 set(BUILD_CMSIS_CORE Off)
 set(BUILD_RETARGET Off)
@@ -266,27 +258,9 @@
 endif()
 
 if (BL2)
-	add_definitions(-DBL2)
-	if (NOT ${MCUBOOT_SIGNATURE_TYPE} STREQUAL "RSA-2048" AND NOT ${MCUBOOT_SIGNATURE_TYPE} STREQUAL "RSA-3072")
-		message(FATAL_ERROR "MCUBoot only supports RSA-2048 and RSA-3072 signature")
-	endif()
-	if (NOT DEFINED MCUBOOT_SIGNATURE_TYPE)
-		set(MCUBOOT_SIGNATURE_TYPE "RSA-3072")
-	endif()
-	if (NOT ${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "OVERWRITE_ONLY" AND
-		NOT ${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "SWAP" AND
-		NOT ${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "NO_SWAP" AND
-		NOT ${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "RAM_LOADING")
-		message(FATAL_ERROR "ERROR: MCUBoot supports OVERWRITE_ONLY, SWAP, NO_SWAP and RAM_LOADING upgrade strategies only.")
-	endif()
 	if (${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "NO_SWAP")
 		set(LINK_TO_BOTH_MEMORY_REGION ON)
 	endif()
-else() #BL2 is turned off
-	if (DEFINED MCUBOOT_UPGRADE_STRATEGY)
-		message (WARNING "Ignoring value of MCUBOOT_UPGRADE_STRATEGY as BL2 option is set to False.")
-		unset (MCUBOOT_UPGRADE_STRATEGY)
-	endif()
 endif()
 
 ##Set Mbed TLS compiler flags and variables for audit log and crypto