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 <[email protected]>
This commit is contained in:
Ronald Cron
2025-07-21 09:49:14 +02:00
parent ed4a10661c
commit a2c37b3b2d
+25
View File
@@ -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)