[CMake] Fwd: Per-Component value for CPACK_PACKAGING_INSTALL_PREFIX with RPM Generator
Sam Lunt
sam.lunt at transmarketgroup.com
Mon Dec 18 11:26:04 EST 2017
I am trying to set a per-component value for
CPACK_PACKAGING_INSTALL_PREFIX when using the RPM generator, but I'm
not having any success.
The CMake documentation for CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX says
that "May be used to set per component CPACK_PACKAGING_INSTALL_PREFIX
for relocatable RPM packages." However, this doesn't seem to be the
case (though I may be misunderstanding something).
Here is a simple CMakeLists that demonstrates the problem:
cmake_minimum_required(VERSION 3.8)
project(FooBar
VERSION 0.1.0
)
add_executable(foo foo.cpp)
add_executable(bar bar.cpp)
include(GNUInstallDirs)
install(TARGETS foo
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT Foo_Comp
)
install(TARGETS bar
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT Bar_Comp
)
set(CPACK_PACKAGE_VERSION_MAJOR ${FooBar_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${FooBar_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${FooBar_VERSION_PATCH})
set(CPACK_PACKAGE_RELOCATABLE ON)
set(CPACK_PACKAGING_INSTALL_PREFIX "/tmp/foobar")
set(CPACK_RPM_COMPONENT_INSTALL ON)
#set(CPACK_RPM_FOO_COMP_PACKAGE_PREFIX "/tmp/foo")
#set(CPACK_RPM_BAR_COMP_PACKAGE_PREFIX "/tmp/bar")
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/tmp")
include(CPack)
As is, the example works fine: when the target install is built, the
executables are installed to
${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}, and when the RPM is
generated and used to install the files, they go to
${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}.
Importantly, the RPM is relocatable (i.e. --prefix and --relocate are
no longer supported with the rpm command).
The issue is when the commented-out lines are uncommented. Instead of
installing each component to its respective packaging prefix, they are
still installed using CPACK_PACKAGING_INSTALL_PREFIX, but now they are
no longer relocatable.
If the install commands are changed to:
install(TARGETS foo
DESTINATION "/tmp/foo/${CMAKE_INSTALL_BINDIR}"
COMPONENT Foo_Comp
)
install(TARGETS bar
DESTINATION "/tmp/bar/${CMAKE_INSTALL_BINDIR}"
COMPONENT Bar_Comp
)
then the packages are relocatable and RPM installs them as expected,
but CMAKE_INSTALL_PREFIX no longer works correctly.
Is there a way that I can have relocatable RPMs with different
per-component packaging install prefix without breaking the install
target?
Thanks in advance for any help.
More information about the CMake
mailing list