#------------------------------------------------------------------------------- # Copyright (c) 2021-2023, Arm Limited. All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause # #------------------------------------------------------------------------------- add_library(bl1_1_shared_lib STATIC) add_library(bl1_1_shared_lib_interface INTERFACE) target_include_directories(bl1_1_shared_lib_interface INTERFACE interface $<$:${CMAKE_CURRENT_SOURCE_DIR}/otp> $<$:${MBEDCRYPTO_PATH}/include> $<$:${CMAKE_CURRENT_SOURCE_DIR}/pq_crypto> ) target_link_libraries(bl1_1_shared_lib_interface INTERFACE psa_interface tfm_fih_headers ) target_sources(bl1_1_shared_lib PRIVATE $<$:crypto/crypto_mbedcrypto> $<$:trng/trng_dummy.c> ./util.c $<$:./otp/otp_default.c> $<$:./pq_crypto/pq_crypto_psa.c> $<$:${MBEDCRYPTO_PATH}/library/lms.c> $<$:${MBEDCRYPTO_PATH}/library/lmots.c> $<$:${MBEDCRYPTO_PATH}/library/platform_util.c> $<$:${MBEDCRYPTO_PATH}/library/psa_util.c> ) target_link_libraries(bl1_1_shared_lib PUBLIC bl1_1_shared_lib_interface tfm_fih PRIVATE platform_bl1_1 $<$:bl1_1_crypto_mbedcrypto> ) target_compile_options(bl1_1_shared_lib_interface INTERFACE #Prevents warnings caused by C99 static assert workaround -Wno-unused-local-typedefs ) target_compile_definitions(bl1_1_shared_lib_interface INTERFACE $<$:TEST_BL1_1> MCUBOOT_FIH_PROFILE_HIGH $<$:MBEDTLS_CONFIG_FILE="mbedtls-pq-cfg.h"> ) if(TFM_BL1_SOFTWARE_CRYPTO) cmake_policy(SET CMP0079 NEW) set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) set(CMAKE_POLICY_DEFAULT_CMP0048 NEW) set(ENABLE_TESTING OFF) set(ENABLE_PROGRAMS OFF) set(MBEDTLS_FATAL_WARNINGS OFF) set(ENABLE_DOCS OFF) set(INSTALL_MBEDTLS_HEADERS OFF) set(LIB_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/mbedcrypto/install) set(lib_target bl1_1_crypto_mbedcrypto_libs) set(mbedcrypto_target bl1_1_crypto_mbedcrypto) set(mbedtls_target bl1_1_crypto_mbedtls) set(mbedx509_target bl1_1_crypto_mbedx509) set(MBEDTLS_TARGET_PREFIX bl1_1_crypto_) # Mbedcrypto is quite a large lib, and it uses too much memory for it to be # reasonable to build it in debug info. As a compromise, if `debug` build type # is selected mbedcrypto will build under `relwithdebinfo` which preserved debug # symbols whild optimizing space. set(SAVED_BUILD_TYPE ${CMAKE_BUILD_TYPE}) set(CMAKE_BUILD_TYPE ${MBEDCRYPTO_BUILD_TYPE}) add_subdirectory(${MBEDCRYPTO_PATH} ${CMAKE_CURRENT_BINARY_DIR}/mbedcrypto) set(CMAKE_BUILD_TYPE ${SAVED_BUILD_TYPE} CACHE STRING "Build type: [Debug, Release, RelWithDebInfo, MinSizeRel]" FORCE) if(NOT TARGET bl1_1_crypto_mbedcrypto) message(FATAL_ERROR "Target bl1_1_crypto_mbedcrypto does not exist. Have the patches in ${CMAKE_SOURCE_DIR}/lib/ext/mbedcrypto been applied to the mbedcrypto repo at ${MBEDCRYPTO_PATH} ? Hint: The command might be `cd ${MBEDCRYPTO_PATH} && git apply ${CMAKE_SOURCE_DIR}/lib/ext/mbedcrypto/*.patch`") endif() target_include_directories(bl1_1_crypto_mbedcrypto PUBLIC ./crypto ) target_compile_definitions(bl1_1_crypto_mbedcrypto PUBLIC MBEDTLS_CONFIG_FILE="mbedcrypto_config.h" # Workaround for https://github.com/ARMmbed/mbedtls/issues/1077 $<$,$>:MULADDC_CANNOT_USE_R7> ) target_compile_options(bl1_1_crypto_mbedcrypto PRIVATE $<$:-Wno-unused-parameter> $<$:-Wno-unused-parameter> ) endif()