[CMake] Success using CPACK_RPM_POST_INSTALL_SCRIPT_FILE

Eric Noulard eric.noulard at gmail.com
Wed Sep 1 06:39:16 EDT 2010


2010/9/1 Yvan BARTHÉLEMY <ybart.lists at gmail.com>:
> Hi,
>
> Since I had some difficulties to use
> CPACK_RPM_POST_INSTALL_SCRIPT_FILE, i would like to share the failing
> steps I tried and their solution.
>
> First I tried to setup a project containing only one script to be
> included as a post-install script into a rpm archive.
>
> The folder archive is like this
>
> /test.sh : The script to be included as post-install script
> /CMakeLists.txt : A minimal CMakeLists that enlighten the problem
> 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)
>
> The solution is simple, I just needed to change the line:
> SET(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "test.sh")
>
> to:
> 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.
> CPack does not know that test.sh is relative to source tree.

Thank you Yvan to contribute to RPM documented usage and feedback.

I shall add that we could add more sophistication into CPackRPM to make
it "search" for test.sh at different places:
    CMAKE_BINARY_DIR
    CMAKE_SOURCE_DIR
    etc ...
but currently it doesn't seem to be worth effort since specifying
absolute path is enough.


-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list