CMake: collect executables to common location

Install target was extended to copy all artefacts to a
common location with elaborate naming convention.

Change-Id: I529ccd5ffd8bace7d015f093a1c1561c05eac6ff
Signed-off-by: Tamas Ban <tamas.ban@arm.com>
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index 5d9a2a2..822dbbf 100755
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -234,7 +234,7 @@
 					 FULL_BIN      tfm_full
 					 SIGN_BIN      tfm_sign
 					 VENEER_NAME   s_veneers
-					 POSTFIX       _0)
+					 POSTFIX       "_0")
 
 	#Link to secondary memory region(add extra linker flag)
 	set_up_app_build(NS_TARGET      ${PROJECT_NAME}
@@ -243,7 +243,7 @@
 					 FULL_BIN      tfm_full
 					 SIGN_BIN      tfm_sign
 					 VENEER_NAME   s_veneers
-					 POSTFIX       _1)
+					 POSTFIX       "_1")
 else()
 	#Link to primary memory region only
 	set_up_app_build(NS_TARGET      ${PROJECT_NAME}
diff --git a/bl2/ext/mcuboot/CMakeLists.txt b/bl2/ext/mcuboot/CMakeLists.txt
index 0ab7dcd..dfe60a8 100644
--- a/bl2/ext/mcuboot/CMakeLists.txt
+++ b/bl2/ext/mcuboot/CMakeLists.txt
@@ -119,7 +119,6 @@
 target_link_libraries(${PROJECT_NAME} "${MBEDTLS_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX_C}mbedcrypto${CMAKE_STATIC_LIBRARY_SUFFIX_C}")
 add_dependencies(${PROJECT_NAME} ${MBEDTLS_TARGET_NAME}_install)
 
-
 #Generate binary file from axf
 compiler_generate_binary_output(${PROJECT_NAME})
 
diff --git a/bl2/ext/mcuboot/MCUBoot.cmake b/bl2/ext/mcuboot/MCUBoot.cmake
index cdcfcbd..7ad81c8 100644
--- a/bl2/ext/mcuboot/MCUBoot.cmake
+++ b/bl2/ext/mcuboot/MCUBoot.cmake
@@ -29,6 +29,14 @@
 		message(FATAL_ERROR "mcuboot_create_boot_payload(): mandatory parameter 'SIGN_BIN' missing.")
 	endif()
 
+	if (DEFINED _MY_PARAMS_POSTFIX)
+		if (${_MY_PARAMS_POSTFIX} STREQUAL "_0")
+			set(MY_POSTFIX "0")
+		else()
+			set(MY_POSTFIX "1")
+		endif()
+	endif()
+
 	#Find Python3.x interpreter
 	find_package(PythonInterp 3)
 	if (NOT PYTHONINTERP_FOUND)
@@ -54,9 +62,33 @@
 						ARGS sign
 							 -k ${MCUBOOT_DIR}/root-rsa-2048.pem
 							 --align 1
-							 -v 1.0
+							 -v 1.2.3+4
 							 -H 0x400
 							 --pad ${SIGN_BIN_SIZE}
 							 ${CMAKE_BINARY_DIR}/${_MY_PARAMS_FULL_BIN}.bin
 							 ${CMAKE_BINARY_DIR}/${_MY_PARAMS_SIGN_BIN}.bin)
+
+	#Collect executables to common location: build/install/outputs/
+	set(TFM_FULL_NAME tfm_s_ns_concatenated)
+	set(TFM_SIGN_NAME tfm_s_ns_signed)
+
+	if (DEFINED MY_POSTFIX)
+		install(FILES  ${CMAKE_BINARY_DIR}/${_MY_PARAMS_SIGN_BIN}.bin
+				RENAME tfm_sig${MY_POSTFIX}.bin
+				DESTINATION outputs/${TARGET_PLATFORM}/)
+	else()
+		install(FILES ${CMAKE_BINARY_DIR}/${_MY_PARAMS_SIGN_BIN}.bin
+				DESTINATION outputs/${TARGET_PLATFORM}/)
+	endif()
+
+	install(FILES  ${CMAKE_BINARY_DIR}/${_MY_PARAMS_FULL_BIN}.bin
+			DESTINATION  outputs/${TARGET_PLATFORM}/)
+
+	install(FILES  ${CMAKE_BINARY_DIR}/${_MY_PARAMS_FULL_BIN}.bin
+			RENAME ${TFM_FULL_NAME}${_MY_PARAMS_POSTFIX}.bin
+			DESTINATION outputs/fvp/)
+
+	install(FILES  ${CMAKE_BINARY_DIR}/${_MY_PARAMS_SIGN_BIN}.bin
+			RENAME ${TFM_SIGN_NAME}${_MY_PARAMS_POSTFIX}.bin
+			DESTINATION outputs/fvp/)
 endfunction()
\ No newline at end of file
diff --git a/secure_fw/CMakeLists.txt b/secure_fw/CMakeLists.txt
index f451e49..f81a4b3 100644
--- a/secure_fw/CMakeLists.txt
+++ b/secure_fw/CMakeLists.txt
@@ -184,15 +184,16 @@
 		set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Default install location for secure_fw." FORCE)
 	endif()
 
+        #Export files needed to interface external applications at: <build_dir>/install/export/tfm/
 	install(DIRECTORY ${TFM_ROOT_DIR}/interface/include/
-			DESTINATION tfm/inc)
+			DESTINATION export/tfm/inc)
 
 	install(DIRECTORY ${TFM_ROOT_DIR}/interface/src/
-			DESTINATION tfm/src)
+			DESTINATION export/tfm/src)
 
-	install(FILES ${S_VENEER_FILE} DESTINATION tfm/veneers)
+	install(FILES ${S_VENEER_FILE} DESTINATION export/tfm/veneers)
 
-	#Collect executables to common location: build/install/outputs/
+	#Collect executables to common location: <build_dir>/install/outputs/
 	if (DEFINED SECURE_AXF_DIR_PREFIX)
 		set(MY_BINARY_DIR ${SECURE_AXF_DIR_PREFIX})
 	else()
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index b81f46b..f6c8401 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -78,13 +78,12 @@
 				${CMAKE_CURRENT_SOURCE_DIR}/interface/include/svc_core_test_ns.h
 				${CMAKE_CURRENT_SOURCE_DIR}/suites/sst/non_secure/os_wrapper.h
 				${CMAKE_CURRENT_SOURCE_DIR}/interface/include/sst_test_service_svc.h
-				${CMAKE_CURRENT_SOURCE_DIR}/test_services/tfm_sst_test_service/sst_test_service_svc.h
 				${CMAKE_CURRENT_SOURCE_DIR}/test_services/tfm_secure_client_service/tfm_secure_client_service_svc.h
 		DESTINATION tfm/test/inc)
 
 install(TARGETS tfm_non_secure_tests
-		DESTINATION tfm/test/lib
-		PUBLIC_HEADER DESTINATION tfm/test/inc)
+		DESTINATION export/tfm/test/lib
+		PUBLIC_HEADER DESTINATION export/tfm/test/inc)
 
 
 embedded_project_end(tfm_non_secure_tests)