[CMake] RPM package and relocation

Kristian kristianonline28 at gmail.com
Wed May 10 07:26:48 EDT 2017


Hi,

I am creating an RPM package, which on a standard installation should
install the file into /opt/ssp-suite directory. But I want to give the
user the opportunity, to install the package into another directory.

I am doing this with these lines:

> set(INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/ssp-suite)
> install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/ssp/" DESTINATION ${INSTALL_DIR})

and by running cmake with

> cmake -DCMAKE_INSTALL_PREFIX=/opt -V --debug .

But I also need to execute a post script, which runs after installation. I added

> set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/postinstall")

to my CMakeLists.txt and in that script, I am using the RPM variable
$RPM_INSTALL_PREFIX. But during installation, I get this error message

> chmod: cannot access '/usr/usr/bin/startssp': No such file or directory
> warning: %post(ssp-suite-7.1-1.x86_64) scriptlet failed, exit status 1
> Non-fatal POSTIN scriptlet failure in rpm package ssp-suite-7.1-1.x86_64

Can someone give me some hints, how to change / add lines to
CMakeListst.txt and my postinstall script, so that script can be fully
relocatable?


More information about the CMake mailing list