[CMake] MAC OS X bundles

Sean McBride sean at rogue-research.com
Fri Jun 20 16:15:17 EDT 2008


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.

Next best might be to place the VTK/ITK .dylibs in /Frameworks and make
sure their install name uses @executable_path.

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.

-- 
____________________________________________________________
Sean McBride, B. Eng                 sean at rogue-research.com
Rogue Research                        www.rogue-research.com 
Mac Software Developer              Montréal, Québec, Canada




More information about the CMake mailing list