Cmake : post-package step

2019-06-20 01:03发布

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?

标签: cmake
1条回答
Fickle 薄情
2楼-- · 2019-06-20 01:22

Create your own package target.

add_custom_target(mypackage
  COMMAND ${CMAKE_CPACK_COMMAND}
  COMMAND ${CMAKE_COMMAND} -E echo "after packaging"
)
查看更多
登录 后发表回答