Executing a Post Build Batch File using CMake
Build Environment Details
What I am Trying to Achieve
At the end of my build process, I would like to execute a batch file on the zephyr_final target that signs the final image. This is different than the MCU Boot signature and is a custom proprietary signature. I am unable to change the way in which this image is signed as it must be compatible with existing tools used with my product.
Method in Which I am trying to Achieve
Normally, I would do this using add_custom_command(TARGET target_name POST_BUILD
COMMAND "batchfile.bat" batchfile_arguments)
However, I don't believe that the final zephyr target is within the scope of the top-level CMakeLists.txt file. That said, I do not have a lot of experience with CMake as most of my past development was within the IAR toolchain. It's very possible that I am misinterpreting this.
1. Will I be able to use the add_custom_command() CMake function to execute the batch file? If so, can someone provide an example as to how I would do this and what Target I should be using.
2. Is there a better, more appropriate method for doing this within the Zephyr environment.
Any help or guidance is much appreciated!
I have been using `add_custom_command` to sign my generated images like this:
COMMAND west sign -t imgtool --
COMMENT "Running post-build signing step..."
Note that the command won't trigger without the additional `custom_target`. Also, my source directory is child of `zephyrproject/zephyr`, so I can't say for certain that this will work in your case.
Hi Casey,toggle quoted messageShow quoted text
Did you have a look at the global 'extra_post_build_commands' and
'extra_post_build_byproducts' properties mentioned in
Try searching around the source tree to see how it is used and if you
can adapt it to your needs.
On Wed, Apr 13 2022, Casey Shea via lists.zephyrproject.org wrote:
*Build Environment Details*