MantisBT - CMake
View Issue Details
0011735CMakeCPackpublic2011-01-20 14:522011-01-21 02:03
Torsten Rohlfing 
Eric NOULARD 
normalmajoralways
closedfixed 
Apple
CMake 2.8.3 
CMake 2.8.4CMake 2.8.4 
0011735: Generators create empty archives using component groups
Packaging of component groups seems to be completely broken in CMake 2.8.3: generated packages are empty.

The problem seems to be that CPack installs all files in a single file system tree, regardless of what component they belong to, but then expects to package them from per-component trees.
1. Download attached file, "source.tar.gz"
2. tar -xzvf source.tar.gz
3. mkdir build ; cd build; cmake ..
4. make package

Afterwards, running "find _CPack_Packages/" will produce something like the following:

_CPack_Packages/
_CPack_Packages//Darwin
_CPack_Packages//Darwin/TGZ
_CPack_Packages//Darwin/TGZ/SomeToolkit
_CPack_Packages//Darwin/TGZ/SomeToolkit/documentation
_CPack_Packages//Darwin/TGZ/SomeToolkit/documentation/usr
_CPack_Packages//Darwin/TGZ/SomeToolkit/documentation/usr/local
_CPack_Packages//Darwin/TGZ/SomeToolkit/headers
_CPack_Packages//Darwin/TGZ/SomeToolkit/headers/usr
_CPack_Packages//Darwin/TGZ/SomeToolkit/headers/usr/local
_CPack_Packages//Darwin/TGZ/SomeToolkit/libraries
_CPack_Packages//Darwin/TGZ/SomeToolkit/libraries/usr
_CPack_Packages//Darwin/TGZ/SomeToolkit/libraries/usr/local
_CPack_Packages//Darwin/TGZ/SomeToolkit/usr
_CPack_Packages//Darwin/TGZ/SomeToolkit/usr/local
_CPack_Packages//Darwin/TGZ/SomeToolkit/usr/local/doc
_CPack_Packages//Darwin/TGZ/SomeToolkit/usr/local/doc/SOMEFILE
_CPack_Packages//Darwin/TGZ/SomeToolkit/usr/local/include
_CPack_Packages//Darwin/TGZ/SomeToolkit/usr/local/include/header.h
_CPack_Packages//Darwin/TGZ/SomeToolkit-development.tar.gz
_CPack_Packages//Darwin/TGZ/SomeToolkit-runtime.tar.gz

Clearly, the two package files are both installed below

 _CPack_Packages//Darwin/TGZ/SomeToolkit/usr/local/

but the package archives are created from

  _CPack_Packages//Darwin/TGZ/SomeToolkit/documentation
  _CPack_Packages//Darwin/TGZ/SomeToolkit/headers
  _CPack_Packages//Darwin/TGZ/SomeToolkit/libraries

which are empty.
I have observed essentially the same behaviour using PackageMaker generator on Mac and ZIP on Windows.
No tags attached.
related to 0011452closed Eric NOULARD Pack component install for archives breaks MySQL packaging 
gz source.tar.gz (1,040) 2011-01-20 14:52
https://public.kitware.com/Bug/file/3648/source.tar.gz
Issue History
2011-01-20 14:52Torsten RohlfingNew Issue
2011-01-20 14:52Torsten RohlfingFile Added: source.tar.gz
2011-01-20 15:00Eric NOULARDNote Added: 0024965
2011-01-20 15:30Torsten RohlfingNote Added: 0024966
2011-01-20 15:51Torsten RohlfingNote Added: 0024969
2011-01-20 16:07Eric NOULARDAssigned To => Eric NOULARD
2011-01-20 16:07Eric NOULARDStatusnew => assigned
2011-01-20 16:32Eric NOULARDNote Added: 0024972
2011-01-20 16:32Eric NOULARDNote Edited: 0024972bug_revision_view_page.php?bugnote_id=24972#r147
2011-01-20 16:35Eric NOULARDRelationship addedrelated to 0011452
2011-01-20 16:36Eric NOULARDPriorityhigh => normal
2011-01-20 16:36Eric NOULARDResolutionopen => fixed
2011-01-20 16:36Eric NOULARDFixed in Version => CMake 2.8.4
2011-01-20 16:36Eric NOULARDTarget Version => CMake 2.8.4
2011-01-20 16:41Eric NOULARDNote Added: 0024975
2011-01-20 16:51Eric NOULARDNote Added: 0024976
2011-01-20 18:37Torsten RohlfingNote Added: 0024977
2011-01-21 02:03Eric NOULARDNote Added: 0024986
2011-01-21 02:03Eric NOULARDStatusassigned => closed

Notes
(0024965)
Eric NOULARD   
2011-01-20 15:00   
I'm not able to test ON MacOS but I'll try on Linux.

2 questions:

1) Why did you ?
   SET(CPACK_SET_DESTDIR "ON")

2) Could you try with CMake 2.8.4-rc1 ?
(0024966)
Torsten Rohlfing   
2011-01-20 15:30   
I set "CPACK_SET_DESTDIR" because if I don't I get this:

CMake Error at /Users/torsten/tmp/build/cmake_install.cmake:39 (FILE):
  file INSTALL cannot copy file "/Users/torsten/tmp/header.h" to
  "/usr/local/include/header.h".

Will try 2.8.4-rc1 next.
(0024969)
Torsten Rohlfing   
2011-01-20 15:51   
Okay - 2.8.4-rc1 does NOT create empty archive (TGZ at least).

Mostly, though, that seems to be because it is simply ignoring the defined components and groups to create one single joint archive. Apparently this is reverting to pre-2.8.3 behaviour.
(0024972)
Eric NOULARD   
2011-01-20 16:32   
Ok I did test myself on Linux and here comes the full story:

1) Never do such thing like

   INSTALL(FILES header.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ COMPONENT headers)

   instead you should do

   INSTALL(FILES header.h DESTINATION include/ COMPONENT headers)

   If you use ${CMAKE_INSTALL_PREFIX}/include this is an ABSOLUTE
   destination which the reason you need to set(CPACK_SET_DESTDIR "ON")

2) CPack 2.8.2 TGZ (or ZIP) generator did not support component install.

   CPack 2.8.3 does but contains [at least] 2 bugs:
     - the default behavior was to generate several files
       which is a backward compatibilty breakage (see other bug)

     - it seems to contains a bug w.r.t. the DESTDIR "ON" + Component.
       which was currently unoticed


3) CPack 2.8.4 supports component install for TGZ, ZIP and RPM
   but this IS not the default behavior in order to be backward compatible.

   If you want to obtain component for TGZ or ZIP you must define
   set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON")

   and
   set(CPACK_RPM_COMPONENT_INSTALL "ON")
   for RPM.

   RPM won't currently support the DESTDIR ON + Component
   TGZ, ZIP and other archive generator should.


My advices:
   Do not use install rules with absolute path DESTINATION unless you
   really need it.
   Do not CPACK_SET_DESTDIR to ON unless you know you really need it.

(0024975)
Eric NOULARD   
2011-01-20 16:41   
Note that if you want to customize CPack behavior depending on
CPack generator invoked you can use a
CPACK_PROJECT_CONFIG_FILE

see
http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#Overall_usage_.28common_to_all_generators.29 [^]

beginning of up-to-date documentation concerning CPack generator
supporting component is here:
http://www.cmake.org/Wiki/CMake:Component_Install_With_CPack#Principles_of_CPack_Component_Packaging [^]
(0024976)
Eric NOULARD   
2011-01-20 16:51   
Will wait from feedback from Torsten before closing this
(0024977)
Torsten Rohlfing   
2011-01-20 18:37   
Seems to work with 2.8.4 and your suggestions. Thanks for your help Eric!
(0024986)
Eric NOULARD   
2011-01-21 02:03   
You're Welcome.
Note that if you do not use ABSOLUTE install path nor DESTDIR "ON"
this should work with 2.8.3 as well.