From a2c37b3b2d7c2c9a255637c7f5b6c03830f11c52 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Wed, 14 May 2025 09:41:04 +0200 Subject: [PATCH] cmake: library: Add custom targets for generated files Add a custom target that depends on TLS generated files, and make both the static and shared crypto libraries depend on it. This ensures that when both libraries are built, the files are not generated concurrently by the static and shared library targets. Do the same for the x509 libraries. Signed-off-by: Ronald Cron --- library/CMakeLists.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index b6693d1a1..ee0381c03 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -84,6 +84,17 @@ if(GEN_FILES) ${CMAKE_CURRENT_SOURCE_DIR}/../framework/scripts/generate_ssl_debug_helpers.py ${tls_error_headers} ) + + add_custom_target(${MBEDTLS_TARGET_PREFIX}mbedx509_generated_files_target + DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/error.c + ) + + add_custom_target(${MBEDTLS_TARGET_PREFIX}mbedtls_generated_files_target + DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/ssl_debug_helpers_generated.c + ${CMAKE_CURRENT_BINARY_DIR}/version_features.c + ) endif() if(CMAKE_COMPILER_IS_GNUCC) @@ -161,6 +172,13 @@ if(USE_STATIC_MBEDTLS_LIBRARY) target_compile_options(${mbedtls_static_target} PRIVATE ${LIBS_C_FLAGS}) set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls) target_link_libraries(${mbedtls_static_target} PUBLIC ${libs} ${mbedx509_static_target}) + + if(GEN_FILES) + add_dependencies(${mbedx509_static_target} + ${MBEDTLS_TARGET_PREFIX}mbedx509_generated_files_target) + add_dependencies(${mbedtls_static_target} + ${MBEDTLS_TARGET_PREFIX}mbedtls_generated_files_target) + endif() endif(USE_STATIC_MBEDTLS_LIBRARY) if(USE_SHARED_MBEDTLS_LIBRARY) @@ -175,6 +193,13 @@ if(USE_SHARED_MBEDTLS_LIBRARY) target_compile_options(${mbedtls_target} PRIVATE ${LIBS_C_FLAGS}) set_target_properties(${mbedtls_target} PROPERTIES VERSION 4.0.0 SOVERSION 21) target_link_libraries(${mbedtls_target} PUBLIC ${libs} ${mbedx509_target}) + + if(GEN_FILES) + add_dependencies(${mbedx509_target} + ${MBEDTLS_TARGET_PREFIX}mbedx509_generated_files_target) + add_dependencies(${mbedtls_target} + ${MBEDTLS_TARGET_PREFIX}mbedtls_generated_files_target) + endif() endif(USE_SHARED_MBEDTLS_LIBRARY) foreach(target IN LISTS target_libraries)