[CMake] MAC OS X bundles

Bill Hoffman bill.hoffman at kitware.com
Fri Jun 20 16:22:58 EDT 2008


Sean McBride wrote:
> On 6/20/08 5:46 PM, Matthias Riechmann said:
> 
>> what exactly do I have to do to successfully build my applilcation as a 
>> MacOS X bundle? So far I used the parameter "MACOSX_BUNDLE" for the 
>> ADD_EXECUTABLE command and set a lot of properties using the 
>> MACOSX_BUNDLE_* variables. The result is indeed a directory with an 
>> ".app" extension with my application inside. But this is where my 
>> problems begin: My application is dependand on several libraries (Qt, 
>> ITK, VTK) and these libraries are not found when executing my application.
>>
>> While digging in the internet I found out that the problem is related to 
>> the "install_name" option of the linker that tells the application where 
>> to find the libraries and some rpath issues. I discovered a lot of 
>> controversary hints on this topic so now I'm completely clueless.
>>
>> Isn't all I have to do telling the linker to let my application search 
>> for the libraries in a certain path, say 
>> "@executable_path/../Frameworks"? If it is, how do I do it? If it is 
>> not, what do I have to do to get my aplication finding the libraries?
> 
> The "proper Mac solution" would be to build ITK & VTK as frameworks and
> put them in your .app's /Frameworks folder.  However, CMake's framework
> support is, I believe, unfinished so you can't do that.
> 
No, that should work now, and is finished.  However, it would require 
major mods to the ITK/VTK CMakeLists.txt to get it to work.  Not 
something that will be happing soon...

> Next best might be to place the VTK/ITK .dylibs in /Frameworks and make
> sure their install name uses @executable_path.
> 
That is what paraview does, and CMake with the qt gui.  See my previous 
post and the CMakeIngestOSXBundleLibraries.cmake which does call install 
name and fix up all the .dylibs that get sent with cmake.

> All this install name is quite a pain, so what I do is build VTK and ITK
> as static libraries and link them directly into my app.  This also has
> the advantage of letting the linker do dead code stripping, which
> reduces application size significantly since VTK and ITK are so big.
> 
This is better if you can do it.

-Bill




-- 
Bill Hoffman
Kitware, Inc.
28 Corporate Drive
Clifton Park, NY 12065
bill.hoffman at kitware.com
http://www.kitware.com
518-371-3971 (phone and fax)


More information about the CMake mailing list