blob: cb026bae395726b9adb2cb2776bf1c7f1e6b32ec [file] [log] [blame]
Soby Mathew73dad842022-12-16 12:51:01 +00001#
2# SPDX-License-Identifier: BSD-3-Clause
3# SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
4#
5
6find_package(Python3 COMPONENTS Interpreter REQUIRED)
7
8add_library(rmm-mbedtls INTERFACE)
9target_include_directories(rmm-mbedtls INTERFACE ${RMM_SOURCE_DIR}/configs/mbedtls)
10target_compile_definitions(rmm-mbedtls INTERFACE MBEDTLS_CONFIG_FILE=<mbedtls_config.h>)
11
12include_directories(${RMM_SOURCE_DIR}/configs/mbedtls)
13add_compile_definitions(MBEDTLS_CONFIG_FILE=<mbedtls_config.h>)
14
15set(ENABLE_PROGRAMS OFF CACHE BOOL "Setting for mbedtls program")
16set(ENABLE_TESTING OFF CACHE BOOL "Setting for mbedtls tests")
17
18# The CFlags modifications are local in scope and only apply to MbedTLS build
19if(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 ")
28endif()
29
30#
31# Add the mbedtls subdirectory and exclude all targets in mbedtls from
32# default `all` target
33#
34add_subdirectory("${RMM_SOURCE_DIR}/ext/mbedtls" "${CMAKE_BINARY_DIR}/ext/medtls" EXCLUDE_FROM_ALL)
35
36target_link_libraries(rmm-mbedtls INTERFACE mbedtls)