Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame^] | 1 | #------------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2017, Arm Limited. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
| 8 | cmake_minimum_required(VERSION 3.7) |
| 9 | |
| 10 | #Tell cmake where our modules can be found |
| 11 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../cmake) |
| 12 | |
| 13 | #Include common stuff to control cmake. |
| 14 | include("Common/BuildSys") |
| 15 | |
| 16 | #Start an embedded project. |
| 17 | embedded_project_start(CONFIG "${CMAKE_CURRENT_LIST_DIR}/../ConfigDefault.cmake") |
| 18 | project(tfm_ns LANGUAGES ASM C) |
| 19 | embedded_project_fixup() |
| 20 | |
| 21 | set(APP_DIR ${CMAKE_CURRENT_LIST_DIR}) |
| 22 | get_filename_component(TFM_ROOT_DIR ${APP_DIR}/.. ABSOLUTE) |
| 23 | set(INTERFACE_DIR ${TFM_ROOT_DIR}/interface) |
| 24 | |
| 25 | #Set variables |
| 26 | get_filename_component(CMSIS_5_DIR ${TFM_ROOT_DIR}/../CMSIS_5 ABSOLUTE) |
| 27 | |
| 28 | if(NOT EXISTS ${CMSIS_5_DIR}) |
| 29 | message(FATAL_ERROR "Missing CMSIS_5. Please clone the CMSIS_5 repo to directory \"${CMSIS_5_DIR}\".") |
| 30 | endif() |
| 31 | |
| 32 | set(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 | |
| 44 | set(MPS2_SSE200_BUILD_CMSIS_CORE On) |
| 45 | set(MPS2_SSE200_BUILD_RETARGET On) |
| 46 | set(MPS2_SSE200_BUILD_NATIVE_DRIVERS On) |
| 47 | set(MPS2_SSE200_BUILD_MPS2_TIME Off) |
| 48 | set(MPS2_SSE200_BUILD_STARTUP On) |
| 49 | set(MPS2_SSE200_BUILD_TARGET_CFG Off) |
| 50 | set(MPS2_SSE200_BUILD_TARGET_HARDWARE_KEYS Off) |
| 51 | set(MPS2_SSE200_BUILD_CMSIS_DRIVERS On) |
| 52 | set(MPS2_SSE200_BUILD_UART_STDOUT Off) |
| 53 | set(MPS2_SSE200_BUILD_MPS2_BOARD_LEDS On) |
| 54 | set(MPS2_SSE200_BUILD_MPS2_BOARD_TIME On) |
| 55 | include(${TFM_ROOT_DIR}/platform/ext/Mps2SSE200.cmake) |
| 56 | |
| 57 | #Set include directories. |
| 58 | embedded_target_include_directories(TARGET ${PROJECT_NAME} PATH ${TFM_ROOT_DIR}/common/sct ABSOLUTE APPEND) |
| 59 | embedded_target_include_directories(TARGET ${PROJECT_NAME} PATH ${INTERFACE_DIR}/include ABSOLUTE APPEND) |
| 60 | embedded_target_include_directories(TARGET ${PROJECT_NAME} PATH ${TFM_ROOT_DIR} ABSOLUTE APPEND) |
| 61 | embedded_target_include_directories(TARGET ${PROJECT_NAME} PATH ${TFM_ROOT_DIR}/secure_fw/spm ABSOLUTE APPEND) |
| 62 | embedded_target_include_directories(TARGET ${PROJECT_NAME} PATH ${TFM_ROOT_DIR}/secure_fw/core ABSOLUTE APPEND) |
| 63 | embedded_target_include_directories(TARGET ${PROJECT_NAME} PATH ${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Include ABSOLUTE APPEND) |
| 64 | embedded_target_include_directories(TARGET ${PROJECT_NAME} PATH ${CMSIS_5_DIR}/CMSIS/RTOS2/Include ABSOLUTE APPEND) |
| 65 | embedded_target_include_directories(TARGET ${PROJECT_NAME} PATH ${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Config ABSOLUTE APPEND) |
| 66 | |
| 67 | #Create an executable |
| 68 | add_executable(${PROJECT_NAME} ${ALL_SRC_C} ${ALL_SRC_C_NS} ${ALL_SRC_ASM_NS} ${NS_APP_SRC}) |
| 69 | #Add the RTX library |
| 70 | target_link_libraries(${PROJECT_NAME} "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MMN.lib") |
| 71 | #Set macro definitions |
| 72 | target_compile_definitions(${PROJECT_NAME} PRIVATE __thumb2__ __DOMAIN_NS=1 __ARM_FEATURE_CMSE=3 LOG_MSG_HANDLER_MODE_PRINTF_ENABLED |
| 73 | ) |
| 74 | |
| 75 | if (NOT DEFINED CORE_TEST) |
| 76 | message(FATAL_ERROR "Incomplete build configuration: CORE_TEST is undefined. ") |
| 77 | elseif(CORE_TEST) |
| 78 | target_compile_definitions(${PROJECT_NAME} PRIVATE CORE_TEST) |
| 79 | endif() |
| 80 | |
| 81 | if (NOT DEFINED CORE_TEST_SERVICES) |
| 82 | message(FATAL_ERROR "Incomplete build configuration: CORE_TEST_SERVICES is undefined. ") |
| 83 | elseif (CORE_TEST_SERVICES) |
| 84 | set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS " --predefine=\"-DCORE_TEST_SERVICES\"") |
| 85 | endif() |
| 86 | |
| 87 | #Set MCUBOOT specific settings. |
| 88 | if (NOT DEFINED MCUBOOT) |
| 89 | message(FATAL_ERROR "Incomplete build configuration: MCUBOOT is undefined. ") |
| 90 | elseif (MCUBOOT) |
| 91 | set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS " --predefine=\"-DMCUBOOT\"") |
| 92 | endif() |
| 93 | |
| 94 | |
| 95 | if(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) |
| 102 | endif() |
| 103 | |
| 104 | #We depend on the non secure tests. See if the library target is available. |
| 105 | if(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) |
| 110 | else() |
| 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}) |
| 118 | endif() |
| 119 | |
| 120 | #Ensure secure_fw is built before our executable. |
| 121 | add_dependencies(${PROJECT_NAME} tfm_s) |
| 122 | |
| 123 | #Add the veneers to the executable. |
| 124 | set_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. |
| 127 | embedded_project_end(${PROJECT_NAME}) |