Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Marc Moreno Berengue | a1f296f | 2018-01-25 15:21:22 +0000 | [diff] [blame] | 2 | # Copyright (c) 2017-2018, Arm Limited. All rights reserved. |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 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_s LANGUAGES ASM C) |
| 19 | embedded_project_fixup() |
| 20 | |
| 21 | set (SECURE_FW_DIR "${CMAKE_CURRENT_LIST_DIR}") |
| 22 | set (TFM_ROOT_DIR "${SECURE_FW_DIR}/..") |
| 23 | set (TEST_DIR "${TFM_ROOT_DIR}/test") |
| 24 | set (INTERFACE_DIR "${TFM_ROOT_DIR}/interface") |
| 25 | |
| 26 | if(CORE_TEST) |
| 27 | set (TFM_LVL 3) |
| 28 | else() |
| 29 | set (TFM_LVL 1) |
| 30 | endif() |
| 31 | |
| 32 | include(${SECURE_FW_DIR}/spm/CMakeLists.inc) |
| 33 | include(${SECURE_FW_DIR}/core/CMakeLists.inc) |
| 34 | include(${SECURE_FW_DIR}/ns_callable/CMakeLists.inc) |
| 35 | |
Marc Moreno Berengue | a1f296f | 2018-01-25 15:21:22 +0000 | [diff] [blame] | 36 | set(BUILD_CMSIS_CORE On) |
| 37 | set(BUILD_RETARGET On) |
| 38 | set(BUILD_NATIVE_DRIVERS On) |
| 39 | set(BUILD_STARTUP On) |
| 40 | set(BUILD_TARGET_CFG On) |
| 41 | set(BUILD_TARGET_HARDWARE_KEYS On) |
| 42 | set(BUILD_CMSIS_DRIVERS On) |
| 43 | set(BUILD_TIME Off) |
| 44 | set(BUILD_UART_STDOUT On) |
| 45 | set(BUILD_FLASH Off) |
| 46 | if(NOT DEFINED PLATFORM_CMAKE_FILE) |
| 47 | message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.") |
| 48 | elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE}) |
| 49 | message (FATAL_ERROR "Platform specific CMake \"${PLATFORM_CMAKE_FILE}\" file does not exist. Please fix value of PLATFORM_CMAKE_FILE.") |
| 50 | else() |
| 51 | include(${PLATFORM_CMAKE_FILE}) |
| 52 | endif() |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 53 | |
Mate Toth-Pal | 48fc6a0 | 2018-01-24 09:50:14 +0100 | [diff] [blame] | 54 | if(NOT DEFINED S_SCATTER_FILE_NAME) |
| 55 | message(FATAL_ERROR "ERROR: Incomplete Configuration: S_SCATTER_FILE_NAME not defined, Include this file from a Config*.cmake") |
| 56 | endif() |
| 57 | embedded_set_target_linker_file(TARGET tfm_s PATH "${S_SCATTER_FILE_NAME}") |
| 58 | |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 59 | embedded_target_include_directories(TARGET ${PROJECT_NAME} PATH ${TFM_ROOT_DIR} ABSOLUTE APPEND) |
| 60 | |
| 61 | #Specify what we build |
| 62 | add_executable(${PROJECT_NAME} ${ALL_SRC_C} ${ALL_SRC_C_S} ${ALL_SRC_ASM_S}) |
| 63 | |
| 64 | #Adds the test directory |
| 65 | add_subdirectory(${TFM_ROOT_DIR}/test ${CMAKE_BINARY_DIR}/test) |
| 66 | |
| 67 | #Add the secure storage library target |
| 68 | add_subdirectory(${SECURE_FW_DIR}/services/secure_storage) |
| 69 | |
| 70 | add_dependencies(${PROJECT_NAME} tfm_storage) |
| 71 | add_dependencies(${PROJECT_NAME} tfm_secure_tests) |
| 72 | |
| 73 | #Set macro definitions for the project. |
| 74 | embedded_set_target_compile_defines(TARGET ${PROJECT_NAME} LANGUAGE C DEFINES __thumb2__ __ARM_FEATURE_CMSE=3 TFM_LVL=${TFM_LVL} DAUTH_CHIP_DEFAULT APPEND) |
Jamie Fox | 5592db0 | 2017-12-18 16:48:29 +0000 | [diff] [blame] | 75 | |
| 76 | if (REGRESSION OR CORE_TEST) |
| 77 | #The test service veneers may not be referenced in the secure binary so the |
| 78 | #veneer objects are explicitly loaded from the secure tests library. |
| 79 | target_link_libraries(${PROJECT_NAME} tfm_storage $<TARGET_LINKER_FILE:tfm_secure_tests>\(*veneers.o\) tfm_secure_tests) |
| 80 | else() |
| 81 | target_link_libraries(${PROJECT_NAME} tfm_storage) |
| 82 | endif() |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 83 | |
| 84 | set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS " --predefine=\"-DTFM_LVL=${TFM_LVL}\"") |
| 85 | |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 86 | if (NOT DEFINED TFM_PARTITION_TEST_CORE) |
| 87 | message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_TEST_CORE is undefined. ") |
| 88 | elseif (TFM_PARTITION_TEST_CORE) |
| 89 | set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS " --predefine=\"-DTFM_PARTITION_TEST_CORE\"") |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 90 | endif() |
| 91 | |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 92 | if (NOT DEFINED TFM_PARTITION_TEST_SST) |
| 93 | message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_TEST_SST is undefined. ") |
| 94 | elseif (TFM_PARTITION_TEST_SST) |
| 95 | set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS " --predefine=\"-DTFM_PARTITION_TEST_SST\"") |
Jamie Fox | 5592db0 | 2017-12-18 16:48:29 +0000 | [diff] [blame] | 96 | endif() |
| 97 | |
Tamas Ban | 581034a | 2017-12-19 19:54:37 +0000 | [diff] [blame] | 98 | if (NOT DEFINED BL2) |
| 99 | message(FATAL_ERROR "Incomplete build configuration: BL2 is undefined. ") |
| 100 | elseif (BL2) |
| 101 | set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS " --predefine=\"-DBL2\"") |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 102 | endif() |
| 103 | |
| 104 | if(CORE_TEST) |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 105 | embedded_set_target_compile_defines(TARGET ${PROJECT_NAME} LANGUAGE C DEFINES TFM_CORE_DEBUG TFM_PARTITION_TEST_CORE APPEND) |
Tamas Ban | 581034a | 2017-12-19 19:54:37 +0000 | [diff] [blame] | 106 | set(SECURE_AXF_DIR_PREFIX "${CMAKE_BINARY_DIR}/unit_test/") |
| 107 | set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${SECURE_AXF_DIR_PREFIX}) |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 108 | set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS " --predefine=\"-DTFM_PARTITION_TEST_CORE\"") |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 109 | endif() |
| 110 | |
Tamas Ban | 581034a | 2017-12-19 19:54:37 +0000 | [diff] [blame] | 111 | #Generate binary file from axf |
| 112 | compiler_generate_binary_output(${PROJECT_NAME}) |
| 113 | |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 114 | #Configure where we put the CMSE veneers generated by the compiler. |
| 115 | if (NOT DEFINED S_VENEER_FILE) |
| 116 | set(S_VENEER_FILE "${CMAKE_CURRENT_BINARY_DIR}/s_veneers.o") |
| 117 | endif() |
| 118 | compiler_set_cmse_output(${PROJECT_NAME} "${S_VENEER_FILE}") |
| 119 | |
| 120 | #Configure what file shall be installed. |
| 121 | #Set install location. Keep original value to avoid overriding command line |
| 122 | #settings. |
| 123 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
Tamas Ban | 581034a | 2017-12-19 19:54:37 +0000 | [diff] [blame] | 124 | SET(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Default install location for secure_fw." FORCE) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 125 | endif() |
| 126 | |
| 127 | install(DIRECTORY ${TFM_ROOT_DIR}/interface/include/ |
| 128 | DESTINATION tfm/inc) |
| 129 | |
| 130 | install(DIRECTORY ${TFM_ROOT_DIR}/interface/src/ |
| 131 | DESTINATION tfm/src) |
| 132 | |
| 133 | install(FILES ${S_VENEER_FILE} |
| 134 | DESTINATION tfm/veneers) |
| 135 | |
| 136 | #Finally let cmake system apply changes after the whole project is defined. |
| 137 | embedded_project_end(${PROJECT_NAME}) |