Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cmake : post-package step

Tags:

cmake

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?

like image 494
Layfon Weller Avatar asked Feb 18 '14 21:02

Layfon Weller


2 Answers

Create your own package target.

add_custom_target(mypackage
  COMMAND ${CMAKE_CPACK_COMMAND}
  COMMAND ${CMAKE_COMMAND} -E echo "after packaging"
)
like image 97
steveire Avatar answered Sep 30 '22 02:09

steveire


Upd: Since CMake 3.19 there is CPACK_POST_BUILD_SCRIPTS to do any tasks after CPack produced packages.

like image 30
zaufi Avatar answered Sep 30 '22 03:09

zaufi