[CMake] BundleUtilities

David Cole david.cole at kitware.com
Wed Nov 17 15:23:12 EST 2010


Responses inline on this one...


On Wed, Nov 17, 2010 at 1:56 PM, David Doria <daviddoria at gmail.com> wrote:

> The goal is simply this:
>>
>> - given:
>>  -- an executable target, that happens to be a bundle app on the Mac
>>  -- a full path to that bundle in the install tree
>>  -- a list of plugins that you have also already installed in the bundle
>>  -- a list of directories where to find libraries that your executables
>> and plugins depend on
>>
>> that the following CMake code:
>>
>> install(CODE "
>>   include(BundleUtilities)
>>   fixup_bundle(\"${YOUR_BUNDLE_PATH}\" \"\${YOUR_PLUGINS}\"
>> \"${YOUR_LIBRARY_DIRS}\")
>>   " COMPONENT Runtime)
>>
>> will do all the analysis and copying and fixing up of dependent libraries
>> that is mechanically possible...
>>
>> So that you do not even have to mention VTK and Qt to your install rules
>> at all.
>>
>> If you have to say anything about VTK or Qt beyond target_link_libraries,
>> then BundleUtilities is a failure.
>>
>>
>> David C.
>>
>>
> Ok, progress, and more questions:
>
> 1) I think it worked, check it out.:
>
> http://www.vtk.org/Wiki/CMake/CPack/BundleUtilities/Examples/Linux/Automatic
>
> Though the .deb created is 37MB, where when I manually included vtkHybrid.a
> it was only 2MB...
>

It should have a bunch of *.so files in it. And not a single *.a file. .a
library files are not needed at runtime. BundleUtilities should only copy in
runtime prerequisites into the target install directory.


>
> 2) Do I need both the INSTALL(TARGETS... and INSTALL(CODE... ? Could these
> be combined into one command? It seems like there is a lot of duplication (I
> am specifying the executable twice, etc).
>

You should use install(TARGETS for targets that you are building via
add_executable or add_library.

You need the install(CODE for copying in prerequisites and doing fixups
*after* the target has been installed, but still at install time.

So you have to reference some variables multiple times, but you should
eliminate duplication by using variables that make sense for your situation.



>
> 3) Is there a way to lose all the $,\, and " in the syntax? That is,
> change:
>
> fixup_bundle(\"${APPS}\" \"\${YOUR_PLUGINS}\" \"${YOUR_LIBRARY_DIRS}\")
>
> to:
>
> fixup_bundle(${APPS} ${YOUR_PLUGINS} ${YOUR_LIBRARY_DIRS})
>
> That would make it seem much easier to use, even if it really isn't any
> easier :)
>

The escaped double quotes are necessary to get double quotes into the
"install(CODE" that runs at install time. If you don't use them, then you
can't have any spaces in any of the expanded variables. If you don't like
them, write a *.cmake script and use install(SCRIPT instead of install(CODE.



>
> <http://www.vtk.org/Wiki/CMake/CPack/BundleUtilities/Examples/Linux/Automatic>4)
> I'm still not sure what is going on with this business:
>
>     BUNDLE DESTINATION . COMPONENT Runtime
>     RUNTIME DESTINATION bin COMPONENT Runtime
>
> I think a definition of a "bundle" a "destination", a "component" and
> "runtime" should be provided here:
> http://www.itk.org/Wiki/BundleUtilitiesExample
>
>
If the CMake documentation (--help-command install) is unclear about these
things, suggest improvements to the documentation. Why should those
definitions be duplicated outside of the official CMake documentation built
into the CMake code.....?

On the other hand, it's a wiki, so if adding definitions of those things
makes the wiki page clearer to folks who first see it, then by all means,
feel free to make such modifications.




> 5) Why do you have to specify the Library_Dirs? Can't it just use the same
> list that it uses to look for vtkHybrid when I specify it in the
> target_link_libraries:
>
> TARGET_LINK_LIBRARIES(VTKIncludeTest vtkHybrid)
>

Because the fixup_bundle method is called as a cmake script at install time,
and there may be additional locations besides your build tree where these
prerequisites were built. For example, with Qt, if I build it on my Mac, I
put it in a ~/Qt/4.x.x-arch folder -- this is not known to the cmake script
that runs at install time unless you tell it, so we allow programmers to
pass in additional search directories where these things may be found in
case the build products do not reference them by full path.


HTH,
David C.



> David
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20101117/e9abfee4/attachment-0001.htm>


More information about the CMake mailing list