MantisBT - CMake
View Issue Details
0013004CMakeCPackpublic2012-02-29 08:012013-03-04 08:38
Stanislaw Szymczyk 
Eric NOULARD 
normalminoralways
closedfixed 
i386Ubuntu10.04
CMake 2.8.7 
CMake 2.8.10CMake 2.8.10 
0013004: Archive generator (TGZ, ZIP etc) doesn't work if component-based packaging is used with CPACK_SET_DESTDIR set to ON
Component-based packaging doesn't work in CPack archive generator (for example TGZ or ZIP) if CPACK_SET_DESTDIR is set to ON. The following error messages are displayed:

[sszymczy@RR19-19:~/Desktop/ComponentExampleStart/Source/build]$ LANG=C make package
[ 50%] Built target mylib
[100%] Built target mylibapp
Run CPack packaging tool...
CPack: Create package using ZIP
CPack: Install projects
CPack: - Run preinstall target for: MyLib
CPack: - Install project: MyLib
CPack: - Install component: applications
CPack: - Install component: libraries
CPack: - Install component: headers
CPack: Create package
CPack Error: ERROR while packaging files: archive_read_disk_entry_from_file: (Empty error message)
CPack Error: ERROR while packaging files: archive_read_disk_entry_from_file: (Empty error message)
CPack Error: ERROR while packaging files: archive_read_disk_entry_from_file: (Empty error message)
CPack Error: Problem compressing the directory
CPack Error: Error when generating package: MyLib
make: *** [package] Error 1
1. unzip MyLib.zip (attached to the ticket)
2. cd MyLib
3. mkdir build
4. cd build
5. cmake ..
6. make package
No tags attached.
related to 0012606closed Eric NOULARD Archive and STGZ packages don't respect CPACK_PACKAGE_INSTALL_DIRECTORY (patch included) 
related to 0012129closed Eric NOULARD Add top level directory to component install 
related to 0013019closed Kitware Robot The ZIP package generator does not find the files when CPACK_PACKAGING_INSTALL_PREFIX is set 
zip MyLib.zip (1,671) 2012-02-29 08:01
https://public.kitware.com/Bug/file/4238/MyLib.zip
diff cpack_component_packaging_destdir_fix.diff (774) 2012-03-01 02:20
https://public.kitware.com/Bug/file/4242/cpack_component_packaging_destdir_fix.diff
Issue History
2012-02-29 08:01Stanislaw SzymczykNew Issue
2012-02-29 08:01Stanislaw SzymczykFile Added: MyLib.zip
2012-02-29 08:14Eric NOULARDAssigned To => Eric NOULARD
2012-02-29 08:14Eric NOULARDStatusnew => assigned
2012-02-29 08:19Eric NOULARDNote Added: 0028751
2012-02-29 10:15Eric NOULARDNote Added: 0028752
2012-02-29 10:15Eric NOULARDRelationship addedrelated to 0012606
2012-02-29 10:17Eric NOULARDRelationship addedrelated to 0012129
2012-02-29 12:35Stanislaw SzymczykNote Added: 0028754
2012-02-29 13:18Eric NOULARDNote Added: 0028755
2012-03-01 01:38Stanislaw SzymczykNote Added: 0028768
2012-03-01 02:20Stanislaw SzymczykFile Added: cpack_component_packaging_destdir_fix.diff
2012-03-01 02:21Stanislaw SzymczykNote Added: 0028769
2012-03-01 02:34Eric NOULARDNote Added: 0028770
2012-03-06 16:44Eric NOULARDRelationship addedrelated to 0013019
2012-06-20 08:59Stanislaw SzymczykNote Added: 0029764
2012-08-14 17:27Eric NOULARDTarget Version => CMake 2.8.10
2012-08-14 17:28Eric NOULARDNote Added: 0030659
2012-10-14 12:54Eric NOULARDNote Added: 0031229
2012-10-14 12:54Eric NOULARDStatusassigned => resolved
2012-10-14 12:54Eric NOULARDFixed in Version => CMake 2.8.10
2012-10-14 12:54Eric NOULARDResolutionopen => fixed
2013-03-04 08:38Robert MaynardNote Added: 0032471
2013-03-04 08:38Robert MaynardStatusresolved => closed

Notes
(0028751)
Eric NOULARD   
2012-02-29 08:19   
Setting DESTDIR for Archive generator is usually not a good idea?

In fact since CMake 2.8.3 I think setting CPACK_SET_DESTDIR is usually
not necessary at all.

What are the motivation for setting CPACK_SET_DESTDIR to ON?
(0028752)
Eric NOULARD   
2012-02-29 10:15   
I can reproduce the error so I'll investigate it.
However I'd really like to understand why you want to use DESTDIR
with archive generator.

Usually if you want to influence the destination directory of your archive
you use a combination of values of the following variables:

CPACK_PACKAGING_INSTALL_PREFIX
CPACK_PACKAGE_INSTALL_DIRECTORY
CPACK_INCLUDE_TOPLEVEL_DIRECTORY
CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY

usually the usage of CPACK_SET_DESTDIR is due to the fact you
are trying to use.

That said there are some pending bugs concerning Archive generators
and the usage of those vars in the component case.
(0028754)
Stanislaw Szymczyk   
2012-02-29 12:35   
I simply didn't know about CPACK_PACKAGING_INSTALL_PREFIX. CPACK_SET_DESTDIR always worked for me so far, so I expected it to work with component-based packages too.

It would be nice to have all these variables properly documented. It looks like only CPACK_PACKAGE_INSTALL_DIRECTORY is described in the official cmake documentation now.
(0028755)
Eric NOULARD   
2012-02-29 13:18   
CPack documentation enhancement is on the road for 2.8.8 see 0010067.

If you have time you should try CMake git master and try:

cpack --help-variable-list

the list should now be rather comprehensive but user review
of this documentation would be good.

Any missing or erroneous documentation may be reported in the
0010067 as comment I'll try to handle them as they come.

And in fact I just discover that CPACK_SET_DESTDIR is not documented [yet].
This one will be the first on my next CPack doc enhancement list.
(0028768)
Stanislaw Szymczyk   
2012-03-01 01:38   
I investigated the problem a bit and found the following:

1. The problem is caused by a loop populating the File field of each component (cmCPackGenerator.cxx, around line 851)

2. When CPACK_SET_DESTDIR is unset, paths processed in this loop look like this:

/home/sszymczy/Desktop/ComponentExampleStart/Source/build/_CPack_Packages/Linux/ZIP/MyLib-1.0.0-Linux/applications//bin/mylibapp

First the install prefix is removed from the path, which leaves /bin/mylibapp, then everything up to first '/' is removed, which results in bin/mylibapp - correct relative file path.

3. When CPACK_SET_DESTDIR is set, paths processed in this loop look like this:

/home/sszymczy/Desktop/ComponentExampleStart/Source/build/_CPack_Packages/Linux/ZIP/MyLib-1.0.0-Linux/libraries/usr/local/lib/libmylib.a

There is no extra '/' character, so removing the prefix and then everything up to first '/' leaves just local/lib/libmylib.a - uncorrect because usr directory is now missing.

I guess that either extra '/' shall be added if CPACK_SET_DESTDIR is set to allow this logic to work, or alternatively '/' shall be removed only if it's the first character of the path resulting from removing the install prefix.

Hope this helps.
(0028769)
Stanislaw Szymczyk   
2012-03-01 02:21   
I attached a patch fixing the problem for me.
(0028770)
Eric NOULARD   
2012-03-01 02:34   
Hi Stanislaw,

Thank you very much for the analysis,
and the patch I'll try to review it over the week-end.
(0029764)
Stanislaw Szymczyk   
2012-06-20 08:59   
Any news about this problem? Are there any changes needed in the patch?
(0030659)
Eric NOULARD   
2012-08-14 17:28   
I'll be working on this for 2.8.10
(0031229)
Eric NOULARD   
2012-10-14 12:54   
Merge topic 'CPack-ArchiveGen-andDESTIR_ON' into next

ddec053 Make CPACK_SET_DESTDIR work with archive generator + component-based packaging
(0032471)
Robert Maynard   
2013-03-04 08:38   
Closing resolved issues that have not been updated in more than 4 months.