Build: Cmake build system
-- Cmake based build system
-- Only armclang supported currently
Change-Id: I162357439bb1c871cba3a1c614822ef0b7a73e89
Signed-off-by: Abhishek Pandit <abhishek.pandit@arm.com>
diff --git a/secure_fw/CMakeLists.txt b/secure_fw/CMakeLists.txt
new file mode 100644
index 0000000..8ce4e01
--- /dev/null
+++ b/secure_fw/CMakeLists.txt
@@ -0,0 +1,111 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2017, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+cmake_minimum_required(VERSION 3.7)
+
+#Tell cmake where our modules can be found
+list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../cmake)
+
+#Include common stuff to control cmake.
+include("Common/BuildSys")
+
+#Start an embedded project.
+embedded_project_start(CONFIG "${CMAKE_CURRENT_LIST_DIR}/../ConfigDefault.cmake")
+project(tfm_s LANGUAGES ASM C)
+embedded_project_fixup()
+
+set (SECURE_FW_DIR "${CMAKE_CURRENT_LIST_DIR}")
+set (TFM_ROOT_DIR "${SECURE_FW_DIR}/..")
+set (TEST_DIR "${TFM_ROOT_DIR}/test")
+set (INTERFACE_DIR "${TFM_ROOT_DIR}/interface")
+
+if(CORE_TEST)
+ set (TFM_LVL 3)
+else()
+ set (TFM_LVL 1)
+endif()
+
+include(${SECURE_FW_DIR}/spm/CMakeLists.inc)
+include(${SECURE_FW_DIR}/core/CMakeLists.inc)
+include(${SECURE_FW_DIR}/ns_callable/CMakeLists.inc)
+
+set(MPS2_SSE200_BUILD_CMSIS_CORE On)
+set(MPS2_SSE200_BUILD_RETARGET On)
+set(MPS2_SSE200_BUILD_NATIVE_DRIVERS On)
+set(MPS2_SSE200_BUILD_STARTUP On)
+set(MPS2_SSE200_BUILD_TARGET_CFG On)
+set(MPS2_SSE200_BUILD_TARGET_HARDWARE_KEYS On)
+set(MPS2_SSE200_BUILD_CMSIS_DRIVERS On)
+set(MPS2_SSE200_BUILD_MPS2_TIME Off)
+set(MPS2_SSE200_BUILD_UART_STDOUT On)
+set(MPS2_SSE200_BUILD_MPS2_BOARD_LEDS Off)
+set(MPS2_SSE200_BUILD_MPS2_BOARD_TIME On)
+include(${TFM_ROOT_DIR}/platform/ext/Mps2SSE200.cmake)
+
+embedded_target_include_directories(TARGET ${PROJECT_NAME} PATH ${TFM_ROOT_DIR} ABSOLUTE APPEND)
+
+#Specify what we build
+add_executable(${PROJECT_NAME} ${ALL_SRC_C} ${ALL_SRC_C_S} ${ALL_SRC_ASM_S})
+
+#Adds the test directory
+add_subdirectory(${TFM_ROOT_DIR}/test ${CMAKE_BINARY_DIR}/test)
+
+#Add the secure storage library target
+add_subdirectory(${SECURE_FW_DIR}/services/secure_storage)
+
+add_dependencies(${PROJECT_NAME} tfm_storage)
+add_dependencies(${PROJECT_NAME} tfm_secure_tests)
+
+#Set macro definitions for the project.
+embedded_set_target_compile_defines(TARGET ${PROJECT_NAME} LANGUAGE C DEFINES __thumb2__ __ARM_FEATURE_CMSE=3 TFM_LVL=${TFM_LVL} DAUTH_CHIP_DEFAULT APPEND)
+target_link_libraries(${PROJECT_NAME} tfm_storage tfm_secure_tests)
+
+set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS " --predefine=\"-DTFM_LVL=${TFM_LVL}\"")
+
+if (NOT DEFINED CORE_TEST_SERVICES)
+ message(FATAL_ERROR "Incomplete build configuration: CORE_TEST_SERVICES is undefined. ")
+elseif (CORE_TEST_SERVICES)
+ set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS " --predefine=\"-DCORE_TEST_SERVICES\"")
+endif()
+
+if (NOT DEFINED MCUBOOT)
+ message(FATAL_ERROR "Incomplete build configuration: MCUBOOT is undefined. ")
+elseif (MCUBOOT)
+ set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS " --predefine=\"-DMCUBOOT\"")
+endif()
+
+if(CORE_TEST)
+ embedded_set_target_compile_defines(TARGET ${PROJECT_NAME} LANGUAGE C DEFINES TFM_CORE_DEBUG CORE_TEST_SERVICES APPEND)
+ set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/unit_test")
+ set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "--predefine=\"-DCORE_TEST_SERVICES\"")
+endif()
+
+#Configure where we put the CMSE veneers generated by the compiler.
+if (NOT DEFINED S_VENEER_FILE)
+ set(S_VENEER_FILE "${CMAKE_CURRENT_BINARY_DIR}/s_veneers.o")
+endif()
+compiler_set_cmse_output(${PROJECT_NAME} "${S_VENEER_FILE}")
+
+#Configure what file shall be installed.
+#Set install location. Keep original value to avoid overriding command line
+#settings.
+if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
+ SET(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Default install location for secure_fw." FORCE)
+endif()
+
+install(DIRECTORY ${TFM_ROOT_DIR}/interface/include/
+ DESTINATION tfm/inc)
+
+install(DIRECTORY ${TFM_ROOT_DIR}/interface/src/
+ DESTINATION tfm/src)
+
+install(FILES ${S_VENEER_FILE}
+ DESTINATION tfm/veneers)
+
+#Finally let cmake system apply changes after the whole project is defined.
+embedded_project_end(${PROJECT_NAME})
+
diff --git a/secure_fw/core/CMakeLists.inc b/secure_fw/core/CMakeLists.inc
new file mode 100644
index 0000000..0e17845
--- /dev/null
+++ b/secure_fw/core/CMakeLists.inc
@@ -0,0 +1,54 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2017, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+#Definitions to compile the "core" module.
+#This file assumes it will be included from a project specific cmakefile, and
+#will not create a library or executable.
+#Inputs:
+# TFM_ROOT_DIR - directory where secure FW sourec is located.
+#
+#Outputs:
+# Will modify include directories to make the source compile.
+# ALL_SRC_C: C source files to be compiled will be added to this list.
+# This shall be added to your add_executable or add_library command.
+# ALL_SRC_CXX: C++ source files to be compiled will be added to this list.
+# This shall be added to your add_executable or add_library command.
+# ALL_SRC_ASM: assembly source files to be compiled will be added to this
+# list. This shall be added to your add_executable or add_library
+# command.
+# Include directories will be modified by using the include_directories()
+# commands as needed.
+
+#Get the current directory where this file is located.
+set(SS_CORE_DIR ${CMAKE_CURRENT_LIST_DIR})
+if(NOT DEFINED TFM_ROOT_DIR)
+ message(FATAL_ERROR
+ "Please set TFM_ROOT_DIR before including this file.")
+endif()
+
+set (SS_CORE_C_SRC "${SS_CORE_DIR}/tfm_core.c"
+ "${SS_CORE_DIR}/tfm_handler.c"
+ "${SS_CORE_DIR}/tfm_secure_api.c"
+ "${SS_CORE_DIR}/tfm_unpriv_api.c"
+ )
+
+#Append all our source files to global lists.
+list(APPEND ALL_SRC_C ${SS_CORE_C_SRC})
+unset(SS_CORE_C_SRC)
+
+#Setting include directories
+embedded_include_directories(PATH ${TFM_ROOT_DIR} ABSOLUTE)
+embedded_include_directories(PATH ${TFM_ROOT_DIR}/interface/include ABSOLUTE)
+embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/spm ABSOLUTE)
+embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/core ABSOLUTE)
+
+set(PLATFORM_DIR ${TFM_ROOT_DIR}/platform)
+embedded_include_directories(PATH "${PLATFORM_DIR}/cmsis" ABSOLUTE)
+embedded_include_directories(PATH
+ "${PLATFORM_DIR}/target/sse_200_mps2/cmsis_core" ABSOLUTE)
+embedded_include_directories(PATH
+ "${PLATFORM_DIR}//target/sse_200_mps2/sse_200/retarget" ABSOLUTE)
diff --git a/secure_fw/ns_callable/CMakeLists.inc b/secure_fw/ns_callable/CMakeLists.inc
new file mode 100644
index 0000000..25b6493
--- /dev/null
+++ b/secure_fw/ns_callable/CMakeLists.inc
@@ -0,0 +1,37 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2017, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+#Definitions to compile the "NS Callable" module.
+#This file assumes it will be included from a project specific cmakefile, and
+#will not create a library or executable.
+#Inputs:
+# TFM_ROOT_DIR - directory where secure FW source is located.
+#
+#Outputs:
+# Will modify include directories to make the source compile.
+# ALL_SRC_C: C source files to be compiled will be added to this list.
+# This shall be added to the add_executable or add_library command.
+# Include directories will be modified by using the include_directories() commands as needed.
+
+#Get the current directory where this file is located.
+set(SS_NS_CALLABLE_DIR ${CMAKE_CURRENT_LIST_DIR})
+if(NOT DEFINED TFM_ROOT_DIR)
+ message(FATAL_ERROR "Please set TFM_ROOT_DIR before including this file.")
+endif()
+
+set (SS_NS_CALLABLE_C_SRC "${CMAKE_CURRENT_LIST_DIR}/tfm_sst_veneers.c")
+
+#Append all our source files to global lists.
+list(APPEND ALL_SRC_C ${SS_NS_CALLABLE_C_SRC})
+unset(SS_NS_CALLABLE_C_SRC)
+
+#Setting include directories
+embedded_include_directories(PATH ${TFM_ROOT_DIR} ABSOLUTE)
+embedded_include_directories(PATH ${TFM_ROOT_DIR}/interface/include ABSOLUTE)
+embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/spm ABSOLUTE)
+
+
diff --git a/secure_fw/services/secure_storage/BuildMbedtls.cmake b/secure_fw/services/secure_storage/BuildMbedtls.cmake
new file mode 100644
index 0000000..891ada5
--- /dev/null
+++ b/secure_fw/services/secure_storage/BuildMbedtls.cmake
@@ -0,0 +1,76 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2017, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+#When included, this file will add a target to build the mbedtls libraries with
+#the same compilation setting as used by the file including this one.
+cmake_minimum_required(VERSION 3.7)
+
+#Define where mbedtls intermediate output files are stored.
+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.")
+endif()
+
+if(NOT DEFINED MBEDTLS_SOURCE_DIR)
+ message(FATAL_ERROR "Please set MBEDTLS_SOURCE_DIR before including this file.")
+endif()
+
+if(NOT DEFINED MBEDTLS_INSTALL_DIR)
+ message(FATAL_ERROR "Please set MBEDTLS_INSTALL_DIR before including this file.")
+endif()
+
+if(NOT DEFINED MBEDTLS_C_FLAGS)
+ message(FATAL_ERROR "Please set MBEDTLS_C_FLAGS before including this file.")
+endif()
+
+string(APPEND MBEDTLS_C_FLAGS ${CMAKE_C_FLAGS})
+if (NOT TARGET mbedtls_lib AND NOT TARGET mbedtls_lib_install)
+ #Build mbedtls as external project.
+ #This ensures mbedtls is built with exactly defined settings.
+ #mbedtls will be used from is't install location
+ include(ExternalProject)
+ # Add mbed TLS files to the build.
+ set(_static_lib_command ${CMAKE_C_CREATE_STATIC_LIBRARY})
+ externalproject_add(mbedtls_lib
+ SOURCE_DIR ${MBEDTLS_SOURCE_DIR}
+ #Set mbedtls features
+ CMAKE_ARGS -DENABLE_TESTING=OFF -DENABLE_PROGRAMS=OFF
+ #Enforce our build system's settings.
+ CMAKE_ARGS -DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH} -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
+ #Inherit the build setting of this project
+ CMAKE_ARGS -DCMAKE_BUILD_TYPE=${MBEDTLS_BUILD_TYPE}
+ #C compiler settings
+ CMAKE_CACHE_ARGS -DCMAKE_C_COMPILER:string=${CMAKE_C_COMPILER}
+ 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_RELEASE:string=${CMAKE_C_FLAGS_RELEASE}
+ CMAKE_CACHE_ARGS -DCMAKE_C_OUTPUT_EXTENSION:string=.o
+ CMAKE_CACHE_ARGS -DCMAKE_C_COMPILER_WORKS:bool=true
+ #Archiver settings
+ CMAKE_CACHE_ARGS -DCMAKE_AR:string=${CMAKE_AR}
+ CMAKE_CACHE_ARGS -DCMAKE_C_CREATE_STATIC_LIBRARY:internal=${_static_lib_command}
+ CMAKE_CACHE_ARGS -DCMAKE_C_LINK_EXECUTABLE:string=${CMAKE_C_LINK_EXECUTABLE}
+ CMAKE_CACHE_ARGS -DCMAKE_STATIC_LIBRARY_PREFIX_C:string=${CMAKE_STATIC_LIBRARY_PREFIX_C}
+ CMAKE_CACHE_ARGS -DCMAKE_STATIC_LIBRARY_PREFIX_CXX:string=${CMAKE_STATIC_LIBRARY_PREFIX_CXX}
+ #Install location
+ CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:string=${MBEDTLS_INSTALL_DIR}
+ #Place for intermediate build files
+ BINARY_DIR ${MBEDTLS_BINARY_DIR})
+
+ #Add an install target to force installation after each mbedtls build. Without
+ #this target installation happens only when a clean mbedtls build is executed.
+ add_custom_target(mbedtls_lib_install
+ COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/mbedtls -- install
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mbedtls
+ COMMENT "Installing mbedtls to ${MBEDTLS_INSTALL_DIR}"
+ VERBATIM)
+ #Make install rule depend on mbedtls library build
+ add_dependencies(mbedtls_lib_install mbedtls_lib)
+endif()
diff --git a/secure_fw/services/secure_storage/CMakeLists.inc b/secure_fw/services/secure_storage/CMakeLists.inc
new file mode 100644
index 0000000..4590df1
--- /dev/null
+++ b/secure_fw/services/secure_storage/CMakeLists.inc
@@ -0,0 +1,90 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2017, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+#Definitions to compile the "secure_storage" module.
+#This file assumes it will be included from a project specific cmakefile, and
+#will not create a library or executable.
+#Inputs:
+# MBEDTLS_INSTALL_DIR - directory where mbedtls headers and libraries can be found.
+# TFM_ROOT_DIR - root directory of the TF-M repository.
+#Outputs:
+# Will modify include directories to make the source compile.
+# ALL_SRC_C: C source files to be compiled will be added to this list. This shall be added to your add_executable or add_library command.
+# ALL_SRC_CXX: C++ source files to be compiled will be added to this list. This shall be added to your add_executable or add_library command.
+# ALL_SRC_ASM: assembly source files to be compiled will be added to this list. This shall be added to your add_executable or add_library command.
+# Include directories will be modified by using the include_directories() commands as needed.
+
+#Get the current directory where this file is located.
+set(SECURE_STORAGE_DIR ${CMAKE_CURRENT_LIST_DIR})
+
+#Check input variables
+if (NOT DEFINED ENABLE_SECURE_STORAGE)
+ message(FATAL_ERROR "Incomplete build configuration: ENABLE_SECURE_STORAGE is undefined. ")
+endif()
+
+if (ENABLE_SECURE_STORAGE)
+ if (NOT DEFINED MBEDTLS_INSTALL_DIR)
+ message(FATAL_ERROR "Please set MBEDTLS_INSTALL_DIR before including this file.")
+ endif()
+
+ if (NOT DEFINED TFM_ROOT_DIR)
+ message(FATAL_ERROR "Please set TFM_ROOT_DIR before including this file.")
+ endif()
+
+ if (NOT DEFINED SST_ENCRYPTION)
+ message(FATAL_ERROR "Incomplete build configuration: SST_ENCRYPTION is undefined. ")
+ endif()
+ if (NOT DEFINED SST_RAM_FS)
+ message(FATAL_ERROR "Incomplete build configuration: SST_RAM_FS is undefined. ")
+ endif()
+ if (NOT DEFINED SST_VALIDATE_METADATA_FROM_FLASH)
+ message(FATAL_ERROR "Incomplete build configuration: SST_VALIDATE_METADATA_FROM_FLASH is undefined. ")
+ endif()
+
+ set (SECURE_STORAGE_C_SRC "${SECURE_STORAGE_DIR}/sst_core.c"
+ "${SECURE_STORAGE_DIR}/sst_core_interface.c"
+ "${SECURE_STORAGE_DIR}/sst_asset_management.c"
+ "${SECURE_STORAGE_DIR}/sst_utils.c"
+ "${SECURE_STORAGE_DIR}/assets/sst_asset_defs.c"
+ "${SECURE_STORAGE_DIR}/flash/sst_flash_memory_mapped.c"
+ )
+
+ if(NOT SST_RAM_FS)
+ list(APPEND SECURE_STORAGE_C_SRC
+ "${SECURE_STORAGE_DIR}/flash/sst_flash_file_mapped.c")
+ endif()
+
+ if (SST_ENCRYPTION)
+ list (APPEND SECURE_STORAGE_C_SRC
+ "${SECURE_STORAGE_DIR}/crypto/sst_crypto_interface.c")
+ set_property(SOURCE ${SECURE_STORAGE_C_SRC} APPEND PROPERTY COMPILE_DEFINITIONS SST_ENCRYPTION)
+ endif()
+
+ if (SST_VALIDATE_METADATA_FROM_FLASH)
+ set_property(SOURCE ${SECURE_STORAGE_C_SRC} APPEND PROPERTY COMPILE_DEFINITIONS SST_VALIDATE_METADATA_FROM_FLASH)
+ endif()
+
+ if (SST_RAM_FS)
+ set_property(SOURCE ${SECURE_STORAGE_C_SRC} APPEND PROPERTY COMPILE_DEFINITIONS SST_RAM_FS)
+ endif()
+
+ #Append all our source files to global lists.
+ list(APPEND ALL_SRC_C ${SECURE_STORAGE_C_SRC})
+ unset(SECURE_STORAGE_C_SRC)
+
+ #Setting include directories
+ embedded_include_directories(PATH ${TFM_ROOT_DIR} ABSOLUTE)
+ embedded_include_directories(PATH ${TFM_ROOT_DIR}/interface/include ABSOLUTE)
+ embedded_include_directories(PATH ${MBEDTLS_INSTALL_DIR} ABSOLUTE)
+ embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/spm ABSOLUTE)
+ embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/core ABSOLUTE)
+
+ set(PLATFORM_DIR ${TFM_ROOT_DIR}/platform)
+ embedded_include_directories(PATH "${PLATFORM_DIR}/cmsis" ABSOLUTE)
+ embedded_include_directories(PATH "${PLATFORM_DIR}/target/sse_200_mps2/cmsis_core" ABSOLUTE)
+ embedded_include_directories(PATH "${PLATFORM_DIR}/target/sse_200_mps2/sse_200/retarget" ABSOLUTE)
+endif()
diff --git a/secure_fw/services/secure_storage/CMakeLists.txt b/secure_fw/services/secure_storage/CMakeLists.txt
new file mode 100644
index 0000000..8a654f0
--- /dev/null
+++ b/secure_fw/services/secure_storage/CMakeLists.txt
@@ -0,0 +1,61 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2017, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+cmake_minimum_required(VERSION 3.7)
+
+# Tell cmake where our modules can be found
+list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../../cmake)
+
+#Include common stuff to control cmake.
+include("Common/BuildSys")
+
+#Start an embedded project.
+embedded_project_start(CONFIG "${CMAKE_CURRENT_LIST_DIR}/../../../ConfigDefault.cmake")
+project(tfm_storage LANGUAGES ASM C)
+embedded_project_fixup()
+
+###Some project global settings
+set (SECURE_STORAGE_DIR "${CMAKE_CURRENT_LIST_DIR}")
+get_filename_component(TFM_ROOT_DIR "${SECURE_STORAGE_DIR}/../../.." ABSOLUTE)
+#Define location of mbedtls source, build, and installation directory.
+get_filename_component(MBEDTLS_SOURCE_DIR "${TFM_ROOT_DIR}/../mbedtls" ABSOLUTE)
+set (MBEDTLS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/mbedtls")
+set (MBEDTLS_INSTALL_DIR ${MBEDTLS_BINARY_DIR}/mbedtls_install)
+
+###Get the definition of what files we need to build
+set (ENABLE_SECURE_STORAGE ON)
+include(CMakeLists.inc)
+
+
+###Configure how we build our target
+if(DEFINED CORE_TEST)
+ set (TFM_LVL 3)
+else()
+ set (TFM_LVL 1)
+endif()
+
+#Set build type for mbedtls libraries
+if (MBEDTLS_DEBUG)
+ set(MBEDTLS_BUILD_TYPE "Debug")
+else()
+ set(MBEDTLS_BUILD_TYPE "Release")
+endif()
+
+#Build mbedtls as external project.
+#This ensures mbedtls is built with exactly defined settings.
+#mbedtls will be used from is't install location
+include(BuildMbedtls.cmake)
+
+# Specify what we build (for the secure storage service, build as a static library)
+add_library(tfm_storage STATIC ${ALL_SRC_ASM} ${ALL_SRC_C})
+embedded_set_target_compile_defines(TARGET tfm_storage LANGUAGE C DEFINES __ARM_FEATURE_CMSE=3 __thumb2__ TFM_LVL=${TFM_LVL})
+#Add a dependency on the mbed_tls_lib_install target.
+add_dependencies(tfm_storage mbedtls_lib_install)
+#Ask the compiler to merge the mbedtls and the secure storage libraries.
+compiler_merge_library(DEST tfm_storage LIBS "${MBEDTLS_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX_C}mbedcrypto${CMAKE_STATIC_LIBRARY_SUFFIX_C}")
+
+embedded_project_end(tfm_storage)
diff --git a/secure_fw/spm/CMakeLists.inc b/secure_fw/spm/CMakeLists.inc
new file mode 100644
index 0000000..1808f66
--- /dev/null
+++ b/secure_fw/spm/CMakeLists.inc
@@ -0,0 +1,46 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2017, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+#Definitions to compile the "spm" module.
+#This file assumes it will be included from a project specific cmakefile, and
+#will not create a library or executable.
+#Inputs:
+# TFM_ROOT_DIR - root directory of the TF-M repository.
+#
+#Outputs:
+# Will modify include directories to make the source compile.
+# ALL_SRC_C: C source files to be compiled will be added to this list. This shall be added to your add_executable or add_library command.
+# ALL_SRC_CXX: C++ source files to be compiled will be added to this list. This shall be added to your add_executable or add_library command.
+# ALL_SRC_ASM: assembly source files to be compiled will be added to this list. This shall be added to your add_executable or add_library command.
+# Include directories will be modified by using the include_directories() commands as needed.
+
+#Get the current directory where this file is located.
+set(SS_SPM_DIR ${CMAKE_CURRENT_LIST_DIR})
+if(NOT DEFINED TFM_ROOT_DIR)
+ message(FATAL_ERROR "Please set TFM_ROOT_DIR before including this file.")
+endif()
+
+set (SS_SPM_C_SRC "${SS_SPM_DIR}/mpu_armv8m_drv.c"
+ "${SS_SPM_DIR}/spm_api.c"
+ )
+
+
+#Append all our source files to global lists.
+list(APPEND ALL_SRC_C ${SS_SPM_C_SRC})
+unset(SS_SPM_C_SRC)
+
+#Setting include directories
+embedded_include_directories(PATH ${TFM_ROOT_DIR} ABSOLUTE)
+embedded_include_directories(PATH ${TFM_ROOT_DIR}/interface/include ABSOLUTE)
+embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/spm ABSOLUTE)
+embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/core ABSOLUTE)
+embedded_include_directories(PATH ${TFM_ROOT_DIR} ABSOLUTE)
+
+set(PLATFORM_DIR ${TFM_ROOT_DIR}/platform)
+embedded_include_directories(PATH "${PLATFORM_DIR}/cmsis" ABSOLUTE)
+embedded_include_directories(PATH "${PLATFORM_DIR}/target/sse_200_mps2/cmsis_core" ABSOLUTE)
+embedded_include_directories(PATH "${PLATFORM_DIR}//target/sse_200_mps2/sse_200/retarget" ABSOLUTE)