Depending upon a POST_BUILD of an ExternalProject

Having an issue… I add an external project which is a cmake project which creates an output, then as post build creates additional files, from the main project it then adds targets that depend on these post build files, this seems to work when manually running this as a one-off but is prone to a timing/load issue whereby it can fail because the post build in the external project can run after the project itself has finished. I have browsed the documentation and cannot see any way of linking to the POST_BUILD of an external project, or the generated files, using the DEPENDS argument on a add_custom_target() call - is there any way to do that, perhaps something I’ve missed or overlooked?

Not really AFAIK. ExternalProject works best when everything in the project is also an ExternalProject. For mixing other project builds into your own, FetchContent may be a better way to go.

Cc: @craig.scott

How/where are you adding the POST_BUILD commands? I suspect you’re adding those in a way that isn’t supported, but without seeing the details, I can’t comment further.

POST_BUILD is being added by the underlying code here: https://github.com/zephyrproject-rtos/zephyr/blob/main/CMakeLists.txt#L1888
This is added from the other project by using ExternalProject_Add here: https://github.com/zephyrproject-rtos/zephyr/blob/main/share/sysbuild/cmake/modules/sysbuild_extensions.cmake#L241
Can FetchContent be used without external e.g. web content? The files generated in this case are conversions of elf to hex, bin, etc.

@jmqwerk Both of the links in your last comment are no longer pointing at the same lines. If you’re still interested in this discussion, could you please update that comment to point the links at specific tags or commits? If you can’t edit that comment, please add a new one with the updated details instead.

Issue was worked around in a different way