[CMake] Buggy CPack generator behaviour?
Bjørn Forsman
bjorn.forsman at gmail.com
Wed Jul 27 13:41:31 EDT 2011
Hi all,
I wonder if I've hit some bugs in the CPack generators, specifically
TGZ and DEB. They do not behave as I expect them to. What I expect
them to do is to generate an archive of files that look exactly like
what 'make install' puts in DESTDIR. If this is a wrong assumption
then please tell me.
So based on that assumption, here are the issues:
1. TGZ doesn't populate the archive with all needed parent
directories. A binary that 'make install' puts in
DESTDIR/usr/local/bin is put in <archive_root>/bin with TGZ. I would
have expected the archive to contain <archive_root>/usr/local/bin
(like the DEB generator does). Is there maybe a configuration option
for this?
2. TGZ fails on absolute DESTINATION paths:
CMake Error at /home/bjornfor/eraseme/build/cmake_install.cmake:44 (FILE):
file INSTALL cannot copy file "/home/bjornfor/eraseme/build/hello" to
"/usr/bin/hello".
(And no, I don't want to run as root just to create an archive. If DEB
can handle this so should TGZ.)
3. DEB won't generate a .deb with binaries in /usr/local/bin. Example:
set CMAKE_INSTALL_PREFIX=/usr/local and install(TARGETS hello
DESTINATION bin). 'make install' puts hello in /usr/local/bin but the
.deb contains /usr/bin/hello (missing 'local').
Maybe the last issue is by design because no packaged software should
install to /usr/local. But wouldn't it be nicer if cpack either (1)
tell users that it changed some paths, (2) error out and die or (3) be
"stupid" and allow it?
Can anyone help me with this? Or better yet, fix it? :-)
Here is a script I've been using for playing with these issues:
### begin terminal session ###
topdir=$(pwd)
mkdir eraseme || { echo "Directory exists, aborting."; exit 1; }
cd eraseme
cat << EOF >hello.c
#include <stdio.h>
int main()
{
printf("Hello world\n");
return 0;
}
EOF
mkdir etc
cat << EOF >etc/myconfigfile
# empty
EOF
cat << EOF >CMakeLists.txt
cmake_minimum_required(VERSION 2.6)
add_executable(hello hello.c)
install(TARGETS hello DESTINATION bin)
set(SYSCONFDIR "\${CMAKE_INSTALL_PREFIX}/etc" CACHE PATH "Location for
system configuration files")
set(CPACK_PACKAGE_CONTACT "me at localhost.local")
set(CPACK_GENERATOR "DEB;TGZ")
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
# TGZ generator crashes on absolute paths, DEB doesn't
#install(DIRECTORY etc/ DESTINATION \${SYSCONFDIR})
install(DIRECTORY etc/ DESTINATION .)
include(CPack)
EOF
mkdir build
cd build
cmake ..
make install DESTDIR=${topdir}/eraseme/destdir
make package
echo ""
echo "Install tree:"
#ls -lR $topdir/eraseme/destdir
tree $topdir/eraseme/destdir
echo ""
echo "Contents of DEB:"
ar -x Project-0.1.1-Linux.deb
tar tf data.tar.gz
echo ""
echo "Contents of TGZ:"
tar tf Project-0.1.1-Linux.tar.gz
cd $topdir
### end terminal session ###
Best regards,
Bjørn Forsman
More information about the CMake
mailing list