CPack produce multiple RPMs

I have 1 CMake project.
It produces a number of .so files. Those are then used by Python scripts and by C++ executables.
I’m interested in generated 4 RPMs and perhaps a 5th RPM that is common.

While reading the doc about CPack and CPackComponent modules, and the RPM generator, I’m a little confused.

  1. I am ok to have a 1 single CMake Project? PS: I use the Makefile generator
  2. The ADD_LIBRARY and the ADD_EXECUTABLE that I have produce the .so and the executables.
    I do not have an install() invocations. I do not want to include all the executables generated into rpms (for e.g. tests).
    Will cpack do nothing if I don’t have install() commands?
  3. I have set CPACK_RPM_COMPONENT_INSTALL in the global CMakeLists.txt set to ON.
  4. I am confused about the “Component” world in the cpack context.
    In particular CPACK_RPM_<COMPONENT>_XXXX.
    I see there is concept of component and component group. Forgoing the “group” part, I expect I would have then 5 components in my case.
    Are these components simply the uppercase versions of the targets defined via ADD_LIBRARY or ADD_EXECUTABLE?
    Or do I “define” these components via some cpack way?


The component names are a separate thing to target names. You specify component names as part of calls to install(). You need to make calls to install() if you want to use CPack, otherwise you have to manually write your own CPackConfig.cmake file with all the necessary variables and instructions, and frankly no-one should be doing that except in very unusual circumstances (e.g. packaging something that is not a CMake project).

1 Like