[CMake] CPack and RPM packages

Eric Noulard eric.noulard at gmail.com
Tue Mar 8 07:05:42 EST 2011


2011/3/8 Laszlo Papp <djszapi at archlinux.us>:
> I could not still build cmake...... But I did this modification
> locally you suggested and that is the output:
>
> CPack: Create package using RPM
> CPack: Install projects
> CPack: - Run preinstall target for: Gluon
> CPack: - Install project: Gluon
> CPack: Create package
> CPackRPM: Will use GENERATED spec file:
> /home/meego/gluon/build/_CPack_Packages/Linux/RPM/SPECS/gluon.spec
> CPack: - package: /home/meego/gluon/build/Gluon-0.71.0.rpm.rpm generated.

the double .rpm.rpm extension seems awkward but may be this is a
copy/paste typo?

You can check the content of the generated rpm file using:

$ rpm -qpl  /home/meego/gluon/build/Gluon-0.71.0.rpm

and get the meta-info with:

$ rpm -qpi  /home/meego/gluon/build/Gluon-0.71.0.rpm


> It was a quite slow process after the spec file generation, but it
> seems to work. I do really hope someone can fix the arm - qemu - cmake
> thread hanging issues otherwise no idea how to get this functionality
> working "officially"...

I'm glad it's working now.

Ok now that you can build an rpm,
I think you should really look at the way you install files.

in
https://projects.kde.org/projects/playground/games/gluon/repository/revisions/master/entry/core/CMakeLists.txt
you define:
set(INCLUDE_INSTALL_DIR     ${CMAKE_INSTALL_PREFIX}/include
 CACHE PATH "The subdirectory relative to the install prefix where
header files will be installed.")
set(LIB_INSTALL_DIR         ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}
 CACHE PATH "The subdirectory relative to the install prefix where
libraries will be installed.")
set(SHARE_INSTALL_DIR       ${CMAKE_INSTALL_PREFIX}/share
 CACHE PATH "The subdiractory relative to the install prefix where
data and other files will be installed.")

and then

install(TARGETS GluonCore RUNTIME DESTINATION bin LIBRARY DESTINATION
${LIB_INSTALL_DIR} ARCHIVE DESTINATION ${LIB_INSTALL_DIR} FRAMEWORK
DESTINATION ${LIB_INSTALL_DIR})

so you use absolute destination install path.
If you do so, CPackRPM will automatically set those files as "%config"
files, i.e. files that shouldn't be replaced blindly during an update
or suppressed
when the rpm is removed. (%config are files typically installed in /etc/)
You may end-up with an rpm which does not behave "as usual".

What you [should|could] do to avoid this behavior is:

set(INCLUDE_INSTALL_DIR     include             CACHE PATH "The
subdirectory relative to the install prefix where header files will be
installed.")
set(LIB_INSTALL_DIR         lib${LIB_SUFFIX}    CACHE PATH "The
subdirectory relative to the install prefix where libraries will be
installed.")
set(SHARE_INSTALL_DIR       share               CACHE PATH "The
subdiractory relative to the install prefix where data and other files
will be installed.")

that what xxxx_INSTALL_DIR will become relative and CPackRPM should
behave more the way you expect it should.

In order to be consistent with your DEB packaging you may tell
CPackRPM the dependencies you know:

set(CPACK_RPM_PACKAGE_REQUIRES "libqt4-gui >= 4.6, libqt4-opengl >=
4.6, libopenal1, libsndfile1, libvorbis0a, libgles2")

in the hand-crafted sepc file there is a post-install script.
This can be added with CPackRPM too:

set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE your-post-script.sh)

the file your-post-script.sh should be available (may be in the build
tree or source tree) when the RPM
is built by CPackRPM.



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


More information about the CMake mailing list