I'm looking for a way to execute a code after the packaging is done.
I tried to add a custom target that was depending on the PACKAGE target generated. That looks like it does not work, here's cmake error:
CMake Error: The inter-target dependency graph contains the following strongly connected component (cycle):
"ALL_BUILD" of type UTILITY
depends on "UPLOAD" (strong)
"PACKAGE" of type GLOBAL_TARGET
depends on "ALL_BUILD" (strong)
"UPLOAD" of type UTILITY
depends on "PACKAGE" (strong)
At least one of these targets is not a STATIC_LIBRARY. Cyclic dependencies are allowed only among static libraries.
To do this I used to following code:
add_custom_target(UPLOAD ALL
COMMAND cmake -E echo "Should be post packging!"
)
add_dependencies(UPLOAD PACKAGE)
Is there some way to have the target to UPLOAD the PACKAGEd file?
Create your own package target.
add_custom_target(mypackage
COMMAND ${CMAKE_CPACK_COMMAND}
COMMAND ${CMAKE_COMMAND} -E echo "after packaging"
)
Upd: Since CMake 3.19 there is CPACK_POST_BUILD_SCRIPTS
to do any tasks after CPack produced packages.
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