Build: Add optional install.cmake for platform

Change-Id: I04a935be89964e7c2d3b9fd442d10e4b92baf560
Signed-off-by: Roman Mazurak <Roman.Mazurak@infineon.com>
Signed-off-by: Chris Brand <chris.brand@cypress.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4d15aea..b49456a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,7 @@
 #-------------------------------------------------------------------------------
 # Copyright (c) 2020-2022, Arm Limited. All rights reserved.
+# Copyright (c) 2022 Cypress Semiconductor Corporation (an Infineon company)
+# or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -69,10 +71,6 @@
 
 include(${CMAKE_SOURCE_DIR}/config/check_config.cmake)
 
-if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/check_config.cmake)
-    include(platform/ext/target/${TFM_PLATFORM}/check_config.cmake)
-endif()
-
 ################################################################################
 
 add_subdirectory(lib/ext)
@@ -98,8 +96,8 @@
 
 add_subdirectory(platform)
 
-include(cmake/install.cmake)
-
 if(CRYPTO_HW_ACCELERATOR)
     add_subdirectory(platform/ext/accelerator)
 endif()
+
+include(cmake/install.cmake)
diff --git a/cmake/install.cmake b/cmake/install.cmake
index 8ee9189..a9971de 100644
--- a/cmake/install.cmake
+++ b/cmake/install.cmake
@@ -228,3 +228,9 @@
                 DESTINATION ${INSTALL_INTERFACE_SRC_DIR})
     endif()
 endif()
+
+##################### Platform-specific installation ###########################
+
+if (EXISTS ${CMAKE_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/install.cmake)
+    include(platform/ext/target/${TFM_PLATFORM}/install.cmake)
+endif()
diff --git a/config/check_config.cmake b/config/check_config.cmake
index ef64080..f4360cf 100644
--- a/config/check_config.cmake
+++ b/config/check_config.cmake
@@ -127,3 +127,9 @@
 ###################### Compiler check for FP support ###########################
 
 include(config/cp_check.cmake)
+
+###################### Platform-specific checks ################################
+
+if (EXISTS ${CMAKE_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/check_config.cmake)
+    include(platform/ext/target/${TFM_PLATFORM}/check_config.cmake)
+endif()
diff --git a/docs/integration_guide/platform/platform_ext_folder.rst b/docs/integration_guide/platform/platform_ext_folder.rst
index aa2122c..c586ec8 100644
--- a/docs/integration_guide/platform/platform_ext_folder.rst
+++ b/docs/integration_guide/platform/platform_ext_folder.rst
@@ -170,6 +170,12 @@
 the same format as ``preload.cmake``, but instead details the hardware of the
 NS core that is **not** running the main TF-M secure code.
 
+install.cmake
+^^^^^^^^^^^^^
+
+This optional cmake file is required only if additional files need to be
+installed for the platform.
+
 Flash layout header file
 ------------------------
 Target must provide a header file, called ``flash_layout.h``, which defines the
diff --git a/docs/integration_guide/platform/porting_TFM_to_a_new_hardware.rst b/docs/integration_guide/platform/porting_TFM_to_a_new_hardware.rst
index 2365109..e1a9518 100644
--- a/docs/integration_guide/platform/porting_TFM_to_a_new_hardware.rst
+++ b/docs/integration_guide/platform/porting_TFM_to_a_new_hardware.rst
@@ -250,6 +250,13 @@
 
     [config_cmake_]
 
+install.cmake:
+--------------
+
+    If there are platform-specific files that need to be installed, this file
+    can be provided to do that.
+
+
 startup files:
 ---------------
 
diff --git a/platform/ext/target/cypress/psoc64/CMakeLists.txt b/platform/ext/target/cypress/psoc64/CMakeLists.txt
index 76cf36c..eb9be3e 100644
--- a/platform/ext/target/cypress/psoc64/CMakeLists.txt
+++ b/platform/ext/target/cypress/psoc64/CMakeLists.txt
@@ -1,6 +1,7 @@
 #-------------------------------------------------------------------------------
 # Copyright (c) 2020-2022, Arm Limited. All rights reserved.
-# Copyright (c) 2020-2022, Cypress Semiconductor Corp. All rights reserved.
+# Copyright (c) 2020-2022 Cypress Semiconductor Corporation (an Infineon company)
+# or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -179,29 +180,6 @@
     )
 endif()
 
-########################### export sources #####################################
-
-set(INSTALL_INTERFACE_INC_DIR    ${TFM_INSTALL_PATH}/interface/include)
-set(INSTALL_INTERFACE_SRC_DIR    ${TFM_INSTALL_PATH}/interface/src)
-set(INSTALL_IMAGE_SIGNING_DIR    ${TFM_INSTALL_PATH}/image_signing)
-set(INSTALL_MEMORY_LAYOUT_DIR    ${TFM_INSTALL_PATH}/memory_layout)
-
-install(FILES       mailbox/platform_multicore.c
-                    mailbox/platform_ns_mailbox.c
-        DESTINATION ${INSTALL_INTERFACE_SRC_DIR})
-
-install(FILES       mailbox/platform_multicore.h
-                    mailbox/ns_ipc_config.h
-                    Device/Config/device_cfg.h
-        DESTINATION ${INSTALL_INTERFACE_INC_DIR})
-
-install(FILES       partition/flash_layout.h
-                    partition/region_defs.h
-        DESTINATION ${INSTALL_MEMORY_LAYOUT_DIR})
-
-install(FILES       security/policy/policy_multi_CM0_CM4_tfm_dev_certs.json
-        DESTINATION ${INSTALL_IMAGE_SIGNING_DIR})
-
 #========================= tfm_spm ============================================#
 
 target_sources(tfm_spm
diff --git a/platform/ext/target/cypress/psoc64/install.cmake b/platform/ext/target/cypress/psoc64/install.cmake
new file mode 100644
index 0000000..ba97871
--- /dev/null
+++ b/platform/ext/target/cypress/psoc64/install.cmake
@@ -0,0 +1,26 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020-2021, Arm Limited. All rights reserved.
+# Copyright (c) 2022 Cypress Semiconductor Corporation (an Infineon company)
+# or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+set(INSTALL_MEMORY_LAYOUT_DIR    ${TFM_INSTALL_PATH}/memory_layout)
+
+install(FILES       ${CMAKE_CURRENT_LIST_DIR}/mailbox/platform_multicore.c
+                    ${CMAKE_CURRENT_LIST_DIR}/mailbox/platform_ns_mailbox.c
+        DESTINATION ${INSTALL_INTERFACE_SRC_DIR})
+
+install(FILES       ${CMAKE_CURRENT_LIST_DIR}/mailbox/platform_multicore.h
+                    ${CMAKE_CURRENT_LIST_DIR}/mailbox/ns_ipc_config.h
+                    ${CMAKE_CURRENT_LIST_DIR}/Device/Config/device_cfg.h
+        DESTINATION ${INSTALL_INTERFACE_INC_DIR})
+
+install(FILES       ${CMAKE_CURRENT_LIST_DIR}/partition/flash_layout.h
+                    ${CMAKE_CURRENT_LIST_DIR}/partition/region_defs.h
+        DESTINATION ${INSTALL_MEMORY_LAYOUT_DIR})
+
+install(FILES       ${CMAKE_CURRENT_LIST_DIR}/security/policy/policy_multi_CM0_CM4_tfm_dev_certs.json
+        DESTINATION ${INSTALL_IMAGE_SIGNING_DIR})