Cmake: step after package

I am looking for a way to execute code after packaging is complete.

I tried to add a custom target, which was dependent on the created PACKAGE target. This doesn't seem to work, here is the 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.

For this, I used the following code:

add_custom_target(UPLOAD ALL 
    COMMAND cmake -E echo "Should be post packging!"
)
add_dependencies(UPLOAD PACKAGE)

Is there a way to target the UPLOAD file PACKAGEd?

+2
source share
1 answer

Create your own package goal.

add_custom_target(mypackage
  COMMAND ${CMAKE_CPACK_COMMAND}
  COMMAND ${CMAKE_COMMAND} -E echo "after packaging"
)
+3
source

All Articles