Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2018, Arm Limited. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
| 8 | if(NOT DEFINED REGRESSION) |
| 9 | message(FATAL_ERROR "ERROR: Incomplete Configuration: REGRESSION not defined, Include this file from a Config*.cmake") |
| 10 | elseif(NOT DEFINED CORE_TEST) |
| 11 | message(FATAL_ERROR "ERROR: Incomplete Configuration: CORE_TEST not defined, Include this file from a Config*.cmake") |
| 12 | elseif(NOT DEFINED BL2) |
| 13 | message(FATAL_ERROR "ERROR: Incomplete Configuration: BL2 not defined, Include this file from a Config*.cmake") |
| 14 | endif() |
| 15 | |
Mate Toth-Pal | 48fc6a0 | 2018-01-24 09:50:14 +0100 | [diff] [blame] | 16 | set(BUILD_CMSIS_CORE Off) |
| 17 | set(BUILD_RETARGET Off) |
| 18 | set(BUILD_NATIVE_DRIVERS Off) |
| 19 | set(BUILD_TIME Off) |
| 20 | set(BUILD_STARTUP Off) |
| 21 | set(BUILD_TARGET_CFG Off) |
| 22 | set(BUILD_TARGET_HARDWARE_KEYS Off) |
| 23 | set(BUILD_CMSIS_DRIVERS Off) |
| 24 | set(BUILD_UART_STDOUT Off) |
| 25 | set(BUILD_FLASH Off) |
| 26 | if(NOT DEFINED PLATFORM_CMAKE_FILE) |
| 27 | message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.") |
| 28 | elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE}) |
| 29 | message (FATAL_ERROR "Platform specific CMake \"${PLATFORM_CMAKE_FILE}\" file does not exist. Please fix value of PLATFORM_CMAKE_FILE.") |
| 30 | else() |
| 31 | include(${PLATFORM_CMAKE_FILE}) |
| 32 | endif() |
| 33 | |
Mate Toth-Pal | 7686726 | 2018-03-09 13:15:36 +0100 | [diff] [blame] | 34 | if(NOT DEFINED COMPILER) |
| 35 | message(FATAL_ERROR "ERROR: COMPILER is not set in command line") |
| 36 | elseif(${COMPILER} STREQUAL "ARMCLANG") |
| 37 | #Use any ARMCLANG version found on PATH. Note: Only versions supported by the |
| 38 | #build system will work. A file cmake/Common/CompilerArmClangXY.cmake |
| 39 | #must be present with a matching version. |
| 40 | include("Common/FindArmClang") |
| 41 | include("Common/${ARMCLANG_MODULE}") |
Mate Toth-Pal | 48fc6a0 | 2018-01-24 09:50:14 +0100 | [diff] [blame] | 42 | |
Mate Toth-Pal | 7686726 | 2018-03-09 13:15:36 +0100 | [diff] [blame] | 43 | set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -mfpu=none -mcmse) |
| 44 | ##Shared compiler and linker settings. |
| 45 | function(config_setting_shared_flags tgt) |
| 46 | embedded_set_target_compile_flags(TARGET ${tgt} LANGUAGE C FLAGS -xc -std=c99 ${COMMON_COMPILE_FLAGS} -Wall -Werror) |
| 47 | embedded_set_target_link_flags(TARGET ${tgt} FLAGS --strict --map --symbols --xref --entry=Reset_Handler --info=summarysizes,sizes,totals,unused,veneers) |
| 48 | endfunction() |
| 49 | elseif(${COMPILER} STREQUAL "GNUARM") |
| 50 | #Use any GNUARM version found on PATH. Note: Only versions supported by the |
| 51 | #build system will work. A file cmake/Common/CompilerGNUARMXY.cmake |
| 52 | #must be present with a matching version. |
| 53 | include("Common/FindGNUARM") |
| 54 | include("Common/${GNUARM_MODULE}") |
Mate Toth-Pal | 48fc6a0 | 2018-01-24 09:50:14 +0100 | [diff] [blame] | 55 | |
Mate Toth-Pal | 7686726 | 2018-03-09 13:15:36 +0100 | [diff] [blame] | 56 | set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -msoft-float -mcmse) |
| 57 | ##Shared compiler and linker settings. |
| 58 | function(config_setting_shared_flags tgt) |
| 59 | embedded_set_target_compile_flags(TARGET ${tgt} LANGUAGE C FLAGS -xc -std=c99 ${COMMON_COMPILE_FLAGS} -Wall -Werror -Wno-format -Wno-return-type -Wno-unused-but-set-variable) |
| 60 | #--no-wchar-size-warning flag is added because TF-M sources are compiled |
| 61 | #with short wchars, however the standard library is compiled with normal |
| 62 | #wchar, and this generates linker time warnings. TF-M code does not use |
| 63 | #wchar, so the warning can be suppressed. |
| 64 | embedded_set_target_link_flags(TARGET ${tgt} FLAGS -Xlinker -check-sections -Xlinker -fatal-warnings --entry=Reset_Handler -Wl,--no-wchar-size-warning) |
| 65 | endfunction() |
| 66 | else() |
| 67 | message(FATAL_ERROR "ERROR: Compiler \"${COMPILER}\" is not supported.") |
| 68 | endif() |
| 69 | |
| 70 | #Create a string from the compile flags list, so that it can be used later |
| 71 | #in this file to set mbedtls and BL2 flags |
| 72 | string(REPLACE ";" " " COMMON_COMPILE_FLAGS_STR "${COMMON_COMPILE_FLAGS}") |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 73 | |
| 74 | #Settings which shall be set for all projects the same way based |
| 75 | # on the variables above. |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 76 | set (TFM_PARTITION_TEST_CORE OFF) |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 77 | set (CORE_TEST_POSITIVE OFF) |
| 78 | set (CORE_TEST_INTERACTIVE OFF) |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 79 | set (TFM_PARTITION_TEST_SST OFF) |
Miklos Balint | f13ec02 | 2018-04-06 17:21:22 +0200 | [diff] [blame] | 80 | set (REFERENCE_PLATFORM OFF) |
| 81 | |
| 82 | if(${TARGET_PLATFORM} STREQUAL "AN521" OR ${TARGET_PLATFORM} STREQUAL "AN519") |
| 83 | set (REFERENCE_PLATFORM ON) |
Avinash Mehta | 788036c | 2018-03-15 12:38:43 +0000 | [diff] [blame] | 84 | elseif(${TARGET_PLATFORM} STREQUAL "MUSCA_A") |
| 85 | add_definitions(-DTARGET_MUSCA_A) |
Miklos Balint | f13ec02 | 2018-04-06 17:21:22 +0200 | [diff] [blame] | 86 | endif() |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 87 | |
| 88 | if (REGRESSION) |
| 89 | set(SERVICES_TEST_ENABLED ON) |
| 90 | else() |
| 91 | set(SERVICES_TEST_ENABLED OFF) |
| 92 | endif() |
| 93 | |
| 94 | if (SERVICES_TEST_ENABLED) |
| 95 | set(SERVICE_TEST_S ON) |
| 96 | set(SERVICE_TEST_NS ON) |
Miklos Balint | f13ec02 | 2018-04-06 17:21:22 +0200 | [diff] [blame] | 97 | if (REFERENCE_PLATFORM) |
| 98 | set(CORE_TEST_POSITIVE ON) |
| 99 | endif() |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 100 | endif() |
| 101 | |
| 102 | if (CORE_TEST) |
| 103 | set(CORE_TEST_POSITIVE ON) |
| 104 | set(CORE_TEST_INTERACTIVE OFF) |
| 105 | endif() |
| 106 | |
| 107 | if(CORE_TEST_INTERACTIVE) |
| 108 | add_definitions(-DCORE_TEST_INTERACTIVE) |
| 109 | set(TEST_FRAMEWORK_NS ON) |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 110 | set(TFM_PARTITION_TEST_CORE ON) |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 111 | endif() |
| 112 | |
| 113 | if(CORE_TEST_POSITIVE) |
| 114 | add_definitions(-DCORE_TEST_POSITIVE) |
| 115 | set(TEST_FRAMEWORK_NS ON) |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 116 | set(TFM_PARTITION_TEST_CORE ON) |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 117 | endif() |
| 118 | |
| 119 | if (SERVICE_TEST_S) |
| 120 | add_definitions(-DSERVICES_TEST_S) |
| 121 | set(TEST_FRAMEWORK_S ON) |
| 122 | endif() |
| 123 | |
| 124 | if (SERVICE_TEST_NS) |
| 125 | add_definitions(-DSERVICES_TEST_NS) |
| 126 | set(TEST_FRAMEWORK_NS ON) |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 127 | set(TFM_PARTITION_TEST_SST ON) |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 128 | endif() |
| 129 | |
| 130 | if(TEST_FRAMEWORK_S) |
| 131 | add_definitions(-DTEST_FRAMEWORK_S) |
| 132 | endif() |
| 133 | |
| 134 | if(TEST_FRAMEWORK_NS) |
| 135 | add_definitions(-DTEST_FRAMEWORK_NS) |
| 136 | endif() |
| 137 | |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 138 | if (TFM_PARTITION_TEST_CORE) |
| 139 | add_definitions(-DTFM_PARTITION_TEST_CORE) |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 140 | endif() |
| 141 | |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 142 | if (TFM_PARTITION_TEST_SST) |
| 143 | add_definitions(-DTFM_PARTITION_TEST_SST) |
Jamie Fox | 5592db0 | 2017-12-18 16:48:29 +0000 | [diff] [blame] | 144 | endif() |
| 145 | |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 146 | if (BL2) |
| 147 | add_definitions(-DBL2) |
| 148 | endif() |
| 149 | |
| 150 | ##Secure side |
| 151 | config_setting_shared_flags(tfm_s) |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 152 | |
| 153 | ##Non secure side |
| 154 | config_setting_shared_flags(tfm_ns) |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 155 | |
| 156 | ##TF-M storage |
| 157 | config_setting_shared_flags(tfm_storage) |
Mate Toth-Pal | 7686726 | 2018-03-09 13:15:36 +0100 | [diff] [blame] | 158 | set(MBEDTLS_C_FLAGS "-D__ARM_FEATURE_CMSE=3 -D__thumb2__ ${COMMON_COMPILE_FLAGS_STR} -DMBEDTLS_CONFIG_FILE=\\\\\\\"mbedtls_config.h\\\\\\\" -I${CMAKE_CURRENT_LIST_DIR}/platform/ext/common") |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 159 | |
| 160 | set (SST_ENCRYPTION ON) |
| 161 | set (SST_RAM_FS ON) |
| 162 | set (SST_VALIDATE_METADATA_FROM_FLASH ON) |
| 163 | set (ENABLE_SECURE_STORAGE ON) |
| 164 | set (MBEDTLS_DEBUG ON) |
| 165 | |
Antonio de Angelis | cc657b3 | 2018-02-05 15:56:47 +0000 | [diff] [blame^] | 166 | ##TF-M audit logging |
| 167 | config_setting_shared_flags(tfm_audit) |
| 168 | |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 169 | ##Tests |
| 170 | config_setting_shared_flags(tfm_secure_tests) |
| 171 | config_setting_shared_flags(tfm_non_secure_tests) |
| 172 | |
| 173 | ##BL2 |
| 174 | config_setting_shared_flags(mcuboot) |
Mate Toth-Pal | 7686726 | 2018-03-09 13:15:36 +0100 | [diff] [blame] | 175 | set(MBEDTLS_C_FLAGS_BL2 "-D__ARM_FEATURE_CMSE=3 -D__thumb2__ ${COMMON_COMPILE_FLAGS_STR} -DMBEDTLS_CONFIG_FILE=\\\\\\\"config-boot.h\\\\\\\" -I${CMAKE_CURRENT_LIST_DIR}/bl2/ext/mcuboot/include") |