[CMake] Installing OSX Frameworks

Bill Hoffman bill.hoffman at kitware.com
Wed Jul 23 15:45:44 EDT 2008


Shead, Timothy wrote:
> On 7/23/08 11:14 AM, "Mike Arthur" <mike at mikearthur.co.uk> wrote:
> 
>> On Wednesday 23 July 2008 16:06:21 Mike Jackson wrote:
>>> What would probably be nice at this point would be an example OS X
>>> centric project that uses all these ideas with code explanations for
>>> each step.
>> I think what would be nice is if CMake did this for us! If this is fairly
>> standard when packaging on OSX then it would be good if there were some
>> integration for this, even if we had to specify the relocations manually.
> 
> That's definitely the long-term intent; in the meantime, an intermediate
> solution would be to do the following:
> 
> INSTALL(CODE "EXECUTE_PROCESS(COMMAND install_name_tool -change
> /path/to/external.dylib @executable/external.dylib
> \${CMAKE_INSTALL_PREFIX}/bin/my_binary)")
> 
>  ... for each combination of binary / external dependency.  For a
> reasonably-large project this list gets painfully long, but it does give a
> sense of the scope of the problem ;)
> 
> One improvement on this approach might be a wrapper for install_name_tool
> that would do regex replacements - many similar install names could be
> altered in one-step, or one-at-a-time based on developer preference.
> 

There is also a module in CMake that we have been using for this type of 
thing.  See Modules/GetPrerequisites.cmake.

Which is then used during the install phase by calling it as a script 
something like this:

   install(CODE "set(input_file
 
\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_LOCATION}/APP.app/Contents/MacOS/APP\")")
   install(CODE "set(lib_path 
\"${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}\") ")
   INSTALL(SCRIPT
     "${CMAKE_MODULES}/GetPrerequisites.cmake")

-Bill


More information about the CMake mailing list