cmake: Move copy of crypto libraries to mbedtls

Move copy of crypto libraries to mbedtls as this
copy does not make sense in TF-PSA-Crypto context.
Also copy all of them, not just tfpsacrypto.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
Ronald Cron 2024-11-05 12:21:26 +01:00
parent 8126a686d9
commit 0381a98114
3 changed files with 42 additions and 23 deletions

View File

@ -375,6 +375,24 @@ set(USE_STATIC_TF_PSA_CRYPTO_LIBRARY ${USE_STATIC_MBEDTLS_LIBRARY} CACHE BOOL ""
set(USE_SHARED_TF_PSA_CRYPTO_LIBRARY ${USE_SHARED_MBEDTLS_LIBRARY} CACHE BOOL "")
add_subdirectory(tf-psa-crypto)
set(tf_psa_crypto_library_targets
${MBEDTLS_TARGET_PREFIX}tfpsacrypto
${MBEDTLS_TARGET_PREFIX}builtin
${MBEDTLS_TARGET_PREFIX}everest
${MBEDTLS_TARGET_PREFIX}p256m)
if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY)
list(APPEND tf_psa_crypto_library_targets
${MBEDTLS_TARGET_PREFIX}tfpsacrypto_static
${MBEDTLS_TARGET_PREFIX}builtin_static)
endif()
foreach(target IN LISTS tf_psa_crypto_library_targets)
if(NOT TARGET ${target})
message(FATAL_ERROR "TF-PSA-Crypto target ${target} does not exist.")
endif()
endforeach(target)
add_subdirectory(library)
add_subdirectory(pkgconfig)

View File

@ -208,3 +208,27 @@ add_custom_target(${lib_target} DEPENDS ${mbedx509_target} ${mbedtls_target})
if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY)
add_dependencies(${lib_target} ${mbedx509_static_target} ${mbedtls_static_target})
endif()
foreach(target IN LISTS tf_psa_crypto_library_targets)
get_target_property(target_type ${target} TYPE)
if (target_type STREQUAL STATIC_LIBRARY)
add_custom_command(
TARGET ${mbedtls_target}
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy $<TARGET_FILE:${target}> ${CMAKE_BINARY_DIR}/library)
else()
add_custom_command(
TARGET ${mbedtls_target}
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy $<TARGET_FILE:${target}>
${CMAKE_BINARY_DIR}/library/$<TARGET_FILE_NAME:${target}>)
add_custom_command(
TARGET ${mbedtls_target}
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy $<TARGET_LINKER_FILE:${target}>
${CMAKE_BINARY_DIR}/library/$<TARGET_LINKER_FILE_NAME:${target}>)
endif()
endforeach(target)

View File

@ -156,26 +156,3 @@ foreach(target IN LISTS target_libraries)
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
endforeach(target)
if(USE_STATIC_TF_PSA_CRYPTO_LIBRARY)
add_custom_command(
TARGET ${tfpsacrypto_static_target}
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy $<TARGET_FILE:${tfpsacrypto_static_target}> ${CMAKE_BINARY_DIR}/library)
endif(USE_STATIC_TF_PSA_CRYPTO_LIBRARY)
if(USE_SHARED_TF_PSA_CRYPTO_LIBRARY)
add_custom_command(
TARGET ${tfpsacrypto_target}
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy $<TARGET_FILE:${tfpsacrypto_target}>
${CMAKE_BINARY_DIR}/library/$<TARGET_FILE_NAME:${tfpsacrypto_target}>)
add_custom_command(
TARGET ${tfpsacrypto_target}
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy $<TARGET_LINKER_FILE:${tfpsacrypto_target}>
${CMAKE_BINARY_DIR}/library/$<TARGET_LINKER_FILE_NAME:${tfpsacrypto_target}>)
endif(USE_SHARED_TF_PSA_CRYPTO_LIBRARY)