@@ -188,12 +188,18 @@ if(GEN_FILES)
188188 ${CMAKE_CURRENT_SOURCE_DIR} /../scripts/data_files/driver_templates/psa_crypto_driver_wrappers_no_static.c.jinja
189189 )
190190
191+ add_custom_target (${MBEDTLS_TARGET_PREFIX} mbedcrypto_generated_files_target
192+ DEPENDS
193+ ${CMAKE_CURRENT_BINARY_DIR} /error.c
194+ ${CMAKE_CURRENT_BINARY_DIR} /version_features.c
195+ ${CMAKE_CURRENT_BINARY_DIR} /psa_crypto_driver_wrappers.h
196+ ${CMAKE_CURRENT_BINARY_DIR} /psa_crypto_driver_wrappers_no_static.c
197+ )
191198
192- else ()
193- link_to_source(error.c)
194- link_to_source(version_features.c)
195- link_to_source(ssl_debug_helpers_generated.c)
196- link_to_source(psa_crypto_driver_wrappers_no_static.c)
199+ add_custom_target (${MBEDTLS_TARGET_PREFIX} mbedtls_generated_files_target
200+ DEPENDS
201+ ${CMAKE_CURRENT_BINARY_DIR} /ssl_debug_helpers_generated.c
202+ )
197203endif ()
198204
199205if (CMAKE_COMPILER_IS_GNUCC)
@@ -295,6 +301,13 @@ if(USE_STATIC_MBEDTLS_LIBRARY)
295301 add_library (${mbedtls_static_target} STATIC ${src_tls} )
296302 set_target_properties (${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls)
297303 target_link_libraries (${mbedtls_static_target} PUBLIC ${libs} ${mbedx509_static_target} )
304+
305+ if (GEN_FILES)
306+ add_dependencies (${mbedcrypto_static_target}
307+ ${MBEDTLS_TARGET_PREFIX} mbedcrypto_generated_files_target)
308+ add_dependencies (${mbedtls_static_target}
309+ ${MBEDTLS_TARGET_PREFIX} mbedtls_generated_files_target)
310+ endif ()
298311endif (USE_STATIC_MBEDTLS_LIBRARY)
299312
300313if (USE_SHARED_MBEDTLS_LIBRARY)
@@ -318,6 +331,13 @@ if(USE_SHARED_MBEDTLS_LIBRARY)
318331 add_library (${mbedtls_target} SHARED ${src_tls} )
319332 set_target_properties (${mbedtls_target} PROPERTIES VERSION 3.6.4 SOVERSION 21)
320333 target_link_libraries (${mbedtls_target} PUBLIC ${libs} ${mbedx509_target} )
334+
335+ if (GEN_FILES)
336+ add_dependencies (${mbedcrypto_target}
337+ ${MBEDTLS_TARGET_PREFIX} mbedcrypto_generated_files_target)
338+ add_dependencies (${mbedtls_target}
339+ ${MBEDTLS_TARGET_PREFIX} mbedtls_generated_files_target)
340+ endif ()
321341endif (USE_SHARED_MBEDTLS_LIBRARY)
322342
323343foreach (target IN LISTS target_libraries)
0 commit comments