7

I'm working on a project which generates quite a few executables, libraries and configs, they need to be packed into different packages for deployment. The problem is, the inclusion of those targets/files is not mutual exclusive. One target/file can belong to multiple packages.

I'm using CMake 2.8.9 and trying CPack. I know it's kind of doable with install types. But my platform is Ubuntu, so on Archives/Debs are acceptable and they don't seem to support that.

With components/groups/parent groups it seems only possible to pack one target/file into one component/group.

Is there any way out of this?

Thanks

Ralph Zhang
  • 5,015
  • 5
  • 30
  • 40

2 Answers2

6

Why not use components? If I got it right, you want to generate more then one deb from your project.

I am achieving that like this:

SET(CPACK_DEB_COMPONENT_INSTALL 1)

INSTALL(TARGETS buildA DESTINATION lib/myproj COMPONENT main)
INSTALL(TARGETS buildB DESTINATION include/myproj COMPONENT dev)

When I call make package I get two deb's with the suffixes main and dev containing only what I specified with the INSTALL() statements.

padde
  • 661
  • 8
  • 19
  • 1
    components are mutual exclusive, meaning that you can't pack one item to multiple packages – Ralph Zhang Nov 29 '12 at 01:40
  • Packing same files into multiple packages will lead to conflict between packages during installation. I think components will suit the needs in almost all real life scenarious. – VestniK Mar 20 '15 at 05:19
  • 1
    Package naming isn't flexible: there is no component with an empty name, the component name is appended only at the end of filename. – Velkan Mar 16 '16 at 08:39
5

Well, I'll answer it myself for convinience of late comers: from CMake mail list, I got the answer: with cmake 2.8.9 or earlier (so far), run CPack multiple times with different component settings. That's a bit adhoc but does the job.

Ralph Zhang
  • 5,015
  • 5
  • 30
  • 40
  • To make it work, put: `SET(CPACK_ARCHIVE_COMPONENT_INSTALL ON)` `SET(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE ON)` in CMakeLists.txt and run: `cpack -G ZIP -D CPACK_COMPONENTS_ALL="component_a;common"` `cpack -G ZIP -D CPACK_COMPONENTS_ALL="component_b;common"` – Senyai Apr 29 '14 at 14:39