Soby Mathew | 73dad84 | 2022-12-16 12:51:01 +0000 | [diff] [blame^] | 1 | # |
| 2 | # SPDX-License-Identifier: BSD-3-Clause |
| 3 | # SPDX-FileCopyrightText: Copyright TF-RMM Contributors. |
| 4 | # |
| 5 | |
| 6 | find_package(Python3 COMPONENTS Interpreter REQUIRED) |
| 7 | |
| 8 | add_library(rmm-mbedtls INTERFACE) |
| 9 | target_include_directories(rmm-mbedtls INTERFACE ${RMM_SOURCE_DIR}/configs/mbedtls) |
| 10 | target_compile_definitions(rmm-mbedtls INTERFACE MBEDTLS_CONFIG_FILE=<mbedtls_config.h>) |
| 11 | |
| 12 | include_directories(${RMM_SOURCE_DIR}/configs/mbedtls) |
| 13 | add_compile_definitions(MBEDTLS_CONFIG_FILE=<mbedtls_config.h>) |
| 14 | |
| 15 | set(ENABLE_PROGRAMS OFF CACHE BOOL "Setting for mbedtls program") |
| 16 | set(ENABLE_TESTING OFF CACHE BOOL "Setting for mbedtls tests") |
| 17 | |
| 18 | # The CFlags modifications are local in scope and only apply to MbedTLS build |
| 19 | if(RMM_FPU_USE_AT_REL2) |
| 20 | # Enable using floating point registers for mbed TLS |
| 21 | string(REPLACE "-mgeneral-regs-only" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS}) |
| 22 | # Enable using crypto and sha instructions |
| 23 | string(REGEX REPLACE "(march=[^\\ ]*)" "\\1+sha3+crypto" CMAKE_C_FLAGS ${CMAKE_C_FLAGS}) |
| 24 | # Enable using SHA256 and SHA512 instructions in MbedTLS |
| 25 | string(APPEND CMAKE_C_FLAGS |
| 26 | " -DMBEDTLS_SHA256_USE_A64_CRYPTO_ONLY=1 " |
| 27 | " -DMBEDTLS_SHA512_USE_A64_CRYPTO_ONLY=1 ") |
| 28 | endif() |
| 29 | |
| 30 | # |
| 31 | # Add the mbedtls subdirectory and exclude all targets in mbedtls from |
| 32 | # default `all` target |
| 33 | # |
| 34 | add_subdirectory("${RMM_SOURCE_DIR}/ext/mbedtls" "${CMAKE_BINARY_DIR}/ext/medtls" EXCLUDE_FROM_ALL) |
| 35 | |
| 36 | target_link_libraries(rmm-mbedtls INTERFACE mbedtls) |