blob: 373d596fc1483be001aea5937f0bcaf23dad2b95 [file] [log] [blame]
Gyorgy Szing30fa9872017-12-05 01:08:47 +00001#-------------------------------------------------------------------------------
2# Copyright (c) 2017, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8cmake_minimum_required(VERSION 3.7)
9
10#Tell cmake where our modules can be found
11list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../cmake)
12
13#Include common stuff to control cmake.
14include("Common/BuildSys")
15
16#Start an embedded project.
17embedded_project_start(CONFIG "${CMAKE_CURRENT_LIST_DIR}/../ConfigDefault.cmake")
18project(tfm_ns LANGUAGES ASM C)
19embedded_project_fixup()
20
21set(APP_DIR ${CMAKE_CURRENT_LIST_DIR})
22get_filename_component(TFM_ROOT_DIR ${APP_DIR}/.. ABSOLUTE)
23set(INTERFACE_DIR ${TFM_ROOT_DIR}/interface)
24
25#Set variables
26get_filename_component(CMSIS_5_DIR ${TFM_ROOT_DIR}/../CMSIS_5 ABSOLUTE)
27
28if(NOT EXISTS ${CMSIS_5_DIR})
29 message(FATAL_ERROR "Missing CMSIS_5. Please clone the CMSIS_5 repo to directory \"${CMSIS_5_DIR}\".")
30endif()
31
32set(NS_APP_SRC "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Config/RTX_Config.c"
33 "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Source/rtx_lib.c"
34 "${APP_DIR}/main_ns.c"
35 "${APP_DIR}/ext/tz_context.c"
36 "${APP_DIR}/tfm_integ_test.c"
37 "${APP_DIR}/os_wrapper_rtx.c"
38 "${INTERFACE_DIR}/src/tfm_sst_api.c"
39 "${INTERFACE_DIR}/src/tfm_sst_svc_handler.c"
40 "${INTERFACE_DIR}/src/tfm_id_mngr_dummy.c"
41 "${INTERFACE_DIR}/src/tfm_ns_lock_rtx.c"
42 )
43
44set(MPS2_SSE200_BUILD_CMSIS_CORE On)
45set(MPS2_SSE200_BUILD_RETARGET On)
46set(MPS2_SSE200_BUILD_NATIVE_DRIVERS On)
47set(MPS2_SSE200_BUILD_MPS2_TIME Off)
48set(MPS2_SSE200_BUILD_STARTUP On)
49set(MPS2_SSE200_BUILD_TARGET_CFG Off)
50set(MPS2_SSE200_BUILD_TARGET_HARDWARE_KEYS Off)
51set(MPS2_SSE200_BUILD_CMSIS_DRIVERS On)
52set(MPS2_SSE200_BUILD_UART_STDOUT Off)
53set(MPS2_SSE200_BUILD_MPS2_BOARD_LEDS On)
54set(MPS2_SSE200_BUILD_MPS2_BOARD_TIME On)
55include(${TFM_ROOT_DIR}/platform/ext/Mps2SSE200.cmake)
56
57#Set include directories.
58embedded_target_include_directories(TARGET ${PROJECT_NAME} PATH ${TFM_ROOT_DIR}/common/sct ABSOLUTE APPEND)
59embedded_target_include_directories(TARGET ${PROJECT_NAME} PATH ${INTERFACE_DIR}/include ABSOLUTE APPEND)
60embedded_target_include_directories(TARGET ${PROJECT_NAME} PATH ${TFM_ROOT_DIR} ABSOLUTE APPEND)
61embedded_target_include_directories(TARGET ${PROJECT_NAME} PATH ${TFM_ROOT_DIR}/secure_fw/spm ABSOLUTE APPEND)
62embedded_target_include_directories(TARGET ${PROJECT_NAME} PATH ${TFM_ROOT_DIR}/secure_fw/core ABSOLUTE APPEND)
63embedded_target_include_directories(TARGET ${PROJECT_NAME} PATH ${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Include ABSOLUTE APPEND)
64embedded_target_include_directories(TARGET ${PROJECT_NAME} PATH ${CMSIS_5_DIR}/CMSIS/RTOS2/Include ABSOLUTE APPEND)
65embedded_target_include_directories(TARGET ${PROJECT_NAME} PATH ${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Config ABSOLUTE APPEND)
66
67#Create an executable
68add_executable(${PROJECT_NAME} ${ALL_SRC_C} ${ALL_SRC_C_NS} ${ALL_SRC_ASM_NS} ${NS_APP_SRC})
69#Add the RTX library
70target_link_libraries(${PROJECT_NAME} "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MMN.lib")
71#Set macro definitions
72target_compile_definitions(${PROJECT_NAME} PRIVATE __thumb2__ __DOMAIN_NS=1 __ARM_FEATURE_CMSE=3 LOG_MSG_HANDLER_MODE_PRINTF_ENABLED
73 )
74
75if (NOT DEFINED CORE_TEST)
76 message(FATAL_ERROR "Incomplete build configuration: CORE_TEST is undefined. ")
77elseif(CORE_TEST)
78 target_compile_definitions(${PROJECT_NAME} PRIVATE CORE_TEST)
79endif()
80
81if (NOT DEFINED CORE_TEST_SERVICES)
82 message(FATAL_ERROR "Incomplete build configuration: CORE_TEST_SERVICES is undefined. ")
83elseif (CORE_TEST_SERVICES)
84 set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS " --predefine=\"-DCORE_TEST_SERVICES\"")
85endif()
86
87#Set MCUBOOT specific settings.
88if (NOT DEFINED MCUBOOT)
89 message(FATAL_ERROR "Incomplete build configuration: MCUBOOT is undefined. ")
90elseif (MCUBOOT)
91 set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS " --predefine=\"-DMCUBOOT\"")
92endif()
93
94
95if(NOT TARGET tfm_s)
96 #We need access to the secure veneers. If the location is not already
97 #specified, then set it.
98 if (NOT DEFINED S_VENEER_FILE)
99 set(S_VENEER_FILE "${CMAKE_CURRENT_BINARY_DIR}/s_veneers.o")
100 endif()
101 add_subdirectory(../secure_fw ${CMAKE_CURRENT_BINARY_DIR}/secure_fw)
102endif()
103
104#We depend on the non secure tests. See if the library target is available.
105if(TARGET tfm_non_secure_tests)
106 #If yes, then use the library.
107 target_link_libraries(${PROJECT_NAME} tfm_non_secure_tests)
108 #Ensure library is built first.
109 #add_dependencies(${PROJECT_NAME} tfm_non_secure_tests)
110else()
111 #If not, add the test source to the build.
112 #As of today since secufre_fw is built as a sub-project this code will never
113 #execute.
114 option(ENABLE_INVERT_SERVICE_TESTS "" TRUE)
115 option(ENABLE_SECURE_STORAGE_SERVICE_TESTS "" TRUE)
116 include(../test/CMakeLists.inc)
117 target_sources(${PROJECT_NAME} PUBLIC ${ALL_SRC_C} ${ALL_SRC_C_NS})
118endif()
119
120#Ensure secure_fw is built before our executable.
121add_dependencies(${PROJECT_NAME} tfm_s)
122
123#Add the veneers to the executable.
124set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY LINK_LIBRARIES ${S_VENEER_FILE})
125
126#Finally let cmake system apply changes after the whole project is defined.
127embedded_project_end(${PROJECT_NAME})