Skip to content

Commit 8d524e8

Browse files
Merge pull request #10312 from ronald-cron-arm/dependency-on-generated-files
Backport 3.6: cmake: library: Fix potential concurrent file generation
2 parents 8f4779c + 5491fe3 commit 8d524e8

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Bugfix
2+
* Fix potential CMake parallel build failure when building both the static
3+
and shared libraries.

library/CMakeLists.txt

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
)
197203
endif()
198204

199205
if(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()
298311
endif(USE_STATIC_MBEDTLS_LIBRARY)
299312

300313
if(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()
321341
endif(USE_SHARED_MBEDTLS_LIBRARY)
322342

323343
foreach(target IN LISTS target_libraries)

0 commit comments

Comments
 (0)