[CMake] Support for multiple components in cpack

Thawan Kooburat kthawan at gmail.com
Wed Aug 11 17:08:44 EDT 2010


Hi Eric,

I read though this thread and also two bug reports related to this issue.

It seems like it will take a while because of CPack design issue. Do
you think there will be any workaround or small hack to make this work
with current CPackRPM?


On Tue, Aug 10, 2010 at 7:48 AM, Chris Wolf <cw10025 at gmail.com> wrote:
>
>
> On 8/9/10 2:22 PM, Eric Noulard wrote:
>> 2010/8/9 Chris Wolf <cw10025 at gmail.com>:
>>>
>>>
>>> On 8/9/10 12:11 PM, Kishore wrote:
>>>> On Friday 06 Aug 2010 4:18:36 am Eric Noulard wrote:
>>>>> 2010/8/4 Kishore <kitts.mailinglists at gmail.com>:
>>>>>> On Monday 02 Aug 2010 4:59:47 pm Eric Noulard wrote:
>>>>>>> Hi All,
>>>>>>>
>>>>>>> I did add a patch for the "multiple file problem"
>>>>>>> http://public.kitware.com/Bug/view.php?id=10736
>>>>>>>
>>>>>>> May be interested people can have a try and comment
>>>>>>> this patch.
>>>>>>>
>>>>>>> It adds the possibility  for any CPack generators to generate multiple
>>>>>>> file. It adds "preliminary" support for component to all "Archive
>>>>>>> Generators" (ZIP, TGZ, STGZ etc...) as an example of use.
>>>>>>>
>>>>>>> The change is "backward compatible" in the sense that if
>>>>>>> all CPack generators (but the archive one) behaves as before
>>>>>>> with either componentized  project or not.
>>>>>>>
>>>>>>> Waiting for feedback before going on
>>>>>>
>>>>>> Thanks. It just tried this and it works as claimed. Later today, i will
>>>>>> inspect the generated packages on a windows machine too.
>>>>>
>>>>> Do you have feedback on WIndows?
>>>>
>>>> I tried this on windows today and it works fine there too! :)
>>>>
>>>> While i was with a windows machine, i also noticed that with the NSIS
>>>> installer, installation of libraries was not forced when applications alone
>>>> was chosen. Also, i wonder if there is a way to set which components should be
>>>> preselected. I guess I should just read the documentation first! :)
>>>
>>> I am going to want this on MacOS.  However, on this page:
>>>
>>> http://www.itk.org/Wiki/CMake:Component_Install_With_CPack
>>>
>>> A remark was added on 18 June, which reads:
>>>
>>>    Also, as of the time of this writing, the extensions to CPack
>>>    required to build component-based installers are only available
>>>    via CMake CVS.
>>
>> June yes, but oldish June:  18 June 2008  :-)
>> Clearly the page needs an update :-)
>>
>>> My version of CMake is 2.8.2, which I installed via an installer.  Does this mean
>>> that in order to build a component-based (not monolithic) installer with
>>> PackageMaker, that I need to checkout CMake and built from source?
>>
>> Nope,
>> The PackageMaker seems to already support component installation
>> but apparently only for MacOS > 10.4:
>>
>> from the code:
>> bool cmCPackPackageMakerGenerator::SupportsComponentInstallation() const
>> {
>>   return this->PackageCompatibilityVersion >= 10.4;
>> }
>>
>> I leave the MacOS oriented support to other people because I didn't my hand
>> on a Mac for at least a decade :-)
>
> Actually, it almost works for me, but not quite.  I have three "install" commands,
> one for headers, one for libraries and one for docs.
>
> If I build the installer (for MacOS using the PackageMaker generator) without
> components, then all the stuff, including shared library and it's version
> symlinks, is picked up and will install as expected.
>
> If change to give a "COMPONENT <name>" to each "install" command and
> follow with set(CPACK_COMPONENTS_ALL libs headers docs)
>
> Then a *.mpkg type package is created (multi-package), as expected, and if I run that,
> then I get an optional "customize" button, again, as expected - where
> I can select or deselect the three components.  Unfortunately, the
> "libs" component only includes the static library in it's sub-component,
> so that's all the gets installed.
>
> Again, if I don't use components, then both static and shared libraries,
> including shared library version symlinks, get installed properly.
>
>
> Any ideas?
>
> Thanks,
>
>  -Chris
>
> The relevant pieces of my CMake code are:
>
> add_library(usbDynamic SHARED ${libusb_srcs})
> add_library(usbStatic STATIC ${libusb_srcs})
> set_target_properties(usbDynamic PROPERTIES OUTPUT_NAME usb-1)
> set_target_properties(usbDynamic PROPERTIES VERSION 1.0.8 SOVERSION 0)
> set_target_properties(usbDynamic PROPERTIES
>   INSTALL_NAME_DIR "/usr/local/lib")
>
> set_target_properties(usbStatic PROPERTIES OUTPUT_NAME usb-1.0-static)
> if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
>    target_link_libraries(usbDynamic pthread rt)
> endif()
>
> add_executable(lsusb lsusb.c)
> add_dependencies(lsusb usbDynamic)
> add_dependencies(lsusb libusb.h)
> target_link_libraries(lsusb usb-1)
>
> install(TARGETS usbDynamic usbStatic
>        LIBRARY DESTINATION lib
>        PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
>                    GROUP_READ GROUP_EXECUTE
>                    WORLD_READ WORLD_EXECUTE
>        ARCHIVE DESTINATION lib
>        PERMISSIONS OWNER_READ OWNER_WRITE
>                    GROUP_READ
>                    WORLD_READ
>        COMPONENT libs)
>
> install(FILES libusb.h DESTINATION include/libusb-1.0
>        PERMISSIONS OWNER_READ OWNER_WRITE
>                    GROUP_READ
>                    WORLD_READ
>        COMPONENT headers)
>
> install(DIRECTORY doc/ DESTINATION share/doc/libusb-1.0
>        COMPONENT docs
>        PATTERN doc/*
>        PERMISSIONS OWNER_READ OWNER_WRITE
>                    GROUP_READ
>                    WORLD_READ)
>
> set(CPACK_COMPONENTS_ALL libs headers docs)
> include(CPack)
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>



-- 
Thawan Kooburat

Graduate Student
Department of Computer Science
UW-Madison


More information about the CMake mailing list