[CMake] CPack RPM generator not using CPACK_RPM_<component>_XXX variables

Domen Vrankar domen.vrankar at gmail.com
Tue Feb 2 15:51:31 EST 2016


> set(CPACK_GENERATOR "RPM")
> set(CPACK_RPM_BLAH1_USER_BINARY_SPECFILE
> "${CMAKE_CURRENT_SOURCE_DIR}/install/SPECS/blah1.spec.in")
> set(CPACK_RPM_BLAH1_PACKAGE_PREFIX "${CMAKE_INSTALL_PREFIX}/blah1")
> set(CPACK_RPM_BLAH2_PACKAGE_PREFIX "${CMAKE_INSTALL_PREFIX}/blah2")
> set(CPACK_RPM_COMPONENT_INSTALL ON)
> set(CPACK_COMPONENTS_ALL blah1 blah2)
> include(CPack)
>
> What I want this to do is install blah1 in something like /opt/blah1 and
> install blah2 in /opt/blah2 and use a custom binary spec for component
> blah1. It does none of these things and instead puts both blah1 and blah2 in
> CPACK_PACKAGING_INSTALL_PREFIX and uses a GENERATED binary spec file for
> both blah1 and blah2.

This can be done but not all of those features came in at the same
time so you should check the documentation for the version of
CMake/CPack you are using.

Also for historical reasons there is a difference between CPack
variables and CPackRPM specific variables: with CPACK_* variables the
component part should be in upper case as in your example while with
CPACK_RPM_* variables the component part should be the same as the
name of the component (for e.g. in your case
CPACK_RPM_blah1_PACKAGE_PREFIX).

Also instead of using CPACK_RPM_*_PACKAGE_PREFIX variables you might
also want to take a look at CPACK_RPM_RELOCATION_PATHS that can be
used in combination with GNUInstallDirs.cmake script that comes with
CMake.

e.g.
include(GNUInstallDirs)
set(CPACK_RPM_RELOCATION_PATHS "${CMAKE_INSTALL_INCLUDEDIR}"
  "${CMAKE_INSTALL_LIBDIR}" "${CMAKE_INSTALL_BINDIR}")

This way each rpm package can have more than one install prefix location.

Regards,
Domen


More information about the CMake mailing list