Build: Compile Mbed TLS as MinSizeRel by default

Changes the build system to compile Mbed TLS without debug symbols by
default. It can still be built with debug symbols by adding
-DMBEDTLS_DEBUG=ON to the CMake command. Most of the time TF-M
developers do not need to debug Mbed TLS, and building it as
"MinSizeRel" by default allows for smaller, faster binaries. It also
eliminates the need for Musca-specific build settings to shrink the
binary size.

Change-Id: I4b691a50f63ddbb4707a196bf7950f8e7603a32c
Signed-off-by: Jamie Fox <jamie.fox@arm.com>
diff --git a/BuildMbedtls.cmake b/BuildMbedtls.cmake
index 8985920..d8411da 100644
--- a/BuildMbedtls.cmake
+++ b/BuildMbedtls.cmake
@@ -13,8 +13,8 @@
 set (MBEDTLS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/mbedtls")
 
 #Check input variables
-if(NOT DEFINED MBEDTLS_BUILD_TYPE)
-	message(FATAL_ERROR "Please set MBEDTLS_BUILD_TYPE to 'Debug' or 'Release' before including this file.")
+if(NOT DEFINED MBEDTLS_DEBUG)
+	message(FATAL_ERROR "Please set MBEDTLS_DEBUG to 'OFF' or 'ON' before including this file.")
 endif()
 
 if(NOT DEFINED MBEDTLS_SOURCE_DIR)
@@ -33,6 +33,12 @@
 	message(FATAL_ERROR "Please set MBEDTLS_TARGET_NAME before including this file.")
 endif()
 
+if(MBEDTLS_DEBUG)
+	set(MBEDTLS_BUILD_TYPE "Debug")
+else()
+	set(MBEDTLS_BUILD_TYPE "MinSizeRel")
+endif()
+
 #Based on preinclude input variables, decide if preinclude flags need to be appended
 if((NOT DEFINED MBEDTLS_PREINCLUDE_PREFIX) OR (NOT DEFINED MBEDTLS_PREINCLUDE_HEADER))
 	message(STATUS "Building mbedTLS without pre-included headers and global symbols prefixing.")
@@ -72,6 +78,7 @@
 	CMAKE_CACHE_ARGS -DCMAKE_C_COMPILER_ID:string=${CMAKE_C_COMPILER_ID}
 	CMAKE_CACHE_ARGS -DCMAKE_C_FLAGS:string=${MBEDTLS_C_FLAGS}
 	CMAKE_CACHE_ARGS -DCMAKE_C_FLAGS_DEBUG:string=${CMAKE_C_FLAGS_DEBUG}
+	CMAKE_CACHE_ARGS -DCMAKE_C_FLAGS_MINSIZEREL:string=${CMAKE_C_FLAGS_MINSIZEREL}
 	CMAKE_CACHE_ARGS -DCMAKE_C_FLAGS_RELEASE:string=${CMAKE_C_FLAGS_RELEASE}
 	CMAKE_CACHE_ARGS -DCMAKE_C_OUTPUT_EXTENSION:string=.o
 	CMAKE_CACHE_ARGS -DCMAKE_C_COMPILER_WORKS:bool=true