Tuesday, March 29, 2022

[SOLVED] How to use CPACK_RPM_POST_INSTALL_SCRIPT_FILE?

Issue

Here is the setup I tried using CMake 2.8.2 to reproduce the problem:

/test.sh:

/CMakeLists.txt:

cmake_minimum_required(VERSION 2.8)

SET(CPACK_PACKAGE_NAME test)
SET(CPACK_PACKAGE_VERSION 1.0)

LIST(APPEND CPACK_GENERATOR RPM)

SET(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "test.sh")

INCLUDE(CPack)

then:

mkdir build && cd build && cmake .. && make package

Results:

CPackRPM:Warning: CPACK_RPM_POST_INSTALL_SCRIPT_FILE does not exists - ignoring

How to make the build system aware of my file test.sh ?


Solution

You need to use absolute path:

SET(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/test.sh")

This is needed because CPackRPM needs the absolute path of the file as CPack does not know that test.sh is relative to source tree.



Answered By - ybart
Answer Checked By - Timothy Miller (WPSolving Admin)