When I use the classic gnu Make I put in post build actions like flash the device (if it is a embedded device) and other similiar actions. The actual flashing is usually hidden behind a little sctipt or some commands.
Then I can type something like
make flash
so I first build the code and then it ends up on the target. The classic Makefile could have something like in it:
.PHONY: flash
flash: main.bin
scripts/do_flash.pl main.bin
But how do I add this kind of post build actions to a cmake build?
How do I add a "custom command" that just executes a shellscript?
This questions talks about add_custom_command: The question cmake add custom command feels like it is close, but the add_custom_command seems to need a "output file" to work. But in this case there is something happening, not generated.
What would I put in the CMakeLists.txt to add such a custom action?
/Thanks
For reference, a link into the cmake documentation on this topic
Try this:
add_custom_target(flash
COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/do_flash.pl ${MAIN_BIN_FILE}
DEPENDS ${MAIN_BIN_FILE}
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With