[CMake] CPack per-component value for CPACK_PACKAGING_INSTALL_PREFIX when using RPM generator

Domen Vrankar domen.vrankar at gmail.com
Thu Jan 4 14:51:57 EST 2018


2018-01-03 22:40 GMT+01:00 Sam Lunt <sam.lunt at transmarketgroup.com>:

> I am trying to set a per-component value for
> CPACK_PACKAGING_INSTALL_PREFIX when using the RPM generator, but I
> haven't been able to do so.
>
> I would like to be able to:
> 1. Install using "make install" (or cmake --build ${BUILD_DIR}
> --target install) and have CMAKE_INSTALL_PREFIX control the install
> location
> 2. Generate an rpm file for each component such that the rpm is
> relocatable (i.e. --prefix and --relocate are supported) and each
> component has a different default installation location
>
> The documentation for CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX seems to
> indicate that it is the correct way to set a per-component install
> prefix, since it says that CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX "May
> be used to set per component CPACK_PACKAGING_INSTALL_PREFIX for
> relocatable RPM packages." However, I am only able to successfully use
> this if I provide an absolute path to the install command, but that
> inhibits the use of CMAKE_INSTALL_PREFIX.
>

How about using CPACK_RPM_RELOCATION_PATHS?
https://cmake.org/cmake/help/v3.10/module/CPackRPM.html#variable:CPACK_RPM_RELOCATION_PATHS

install(DIRECTORY DESTINATION ${CMAKE_INSTALL_LIBDIR}/some_dir COMPONENT
libraries)
set(CPACK_RPM_RELOCATION_PATHS "${CMAKE_INSTALL_INCLUDEDIR}"
  "${CMAKE_INSTALL_LIBDIR}")

You specify all the relocation paths for all components and if one or more
of them are found during package generation that path is written to the
package as a relocation path.
You can also use
https://cmake.org/cmake/help/v3.10/module/CPackRPM.html#variable:CPACK_RPM_NO_INSTALL_PREFIX_RELOCATION
to discard CPACK_PACKAGING_INSTALL_PREFIX as a relocation path.

This feature can also (is prefered to) be used in combination with
GNUInstallDirs module (
https://cmake.org/cmake/help/v3.10/module/GNUInstallDirs.html?highlight=gnuinstalldirs
):

include(GNUInstallDirs)

Regards,
Domen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180104/4e53241c/attachment.html>


More information about the CMake mailing list