[vtkusers] Interacting with VTK under Mac OS X

Mike Jackson imikejackson at gmail.com
Fri Mar 16 10:44:01 EDT 2007



On Mar 16, 2007, at 10:32 AM, Sean McBride wrote:

> On 3/16/07 10:25 AM, Martin Costabel said:
>
>> Mike Jackson wrote:
>>> Here is the deal. You have TWO choices. Pick ONE..
>>
>> Unfortunately, both don't make sense when you use a package  
>> manager like
>> MacPorts or Fink or even Xcode. It is a pity that the cmake  
>> developers
>> don't understand this.
>
> Something else that would help greatly is if CMake could build Mac  
> OS X
> frameworks.
>
> There is both a bug and a wiki page advocating this, but things don't
> seem to be moving very fast:
> <http://public.kitware.com/Bug/bug.php?op=show&bugid=886>
> <http://www.cmake.org/Wiki/CMake:MacOSX_Frameworks>
>
> With a framework, the install_name would use @executable_path or
> @loader_path and then be placed in a .app bundle which can be located
> anywhere on the drive.
>
> --
> ____________________________________________________________
> Sean McBride, B. Eng                 sean at rogue-research.com
> Rogue Research                        www.rogue-research.com
> Mac Software Developer              Montréal, Québec, Canada
>
>

With a library, you can do the same thing with the install_name. I  
know frameworks are advocated by Apple, and I like them, but I  
_think_ getting the install_name thing fixed may be easier. With the  
framework approach you have to build the directory structure and all  
that. Don't get me wrong, I would love to see this support in CMake,  
but I'll take anything I can get.

   The sad part is the hack that I did to set the install_name isn't  
that difficult:
I introduce a new variable for OS X: OSX_EMBEDDED_LIBRARY
If this is set, then another option is presented to set the  
install_name prefix (OSX_EMBEDDED_LIBRARY_FOLDER). The default is  
"PlugIns" but the user can change this if they want to anything else.

Here is the relevant part of the Darwin.cmake file that is in the  
following location:

/usr/local/share/cmake-2.4/Modules/Platform/

------------------------------------------

OPTION(OSX_EMBEDDED_LIBRARY OFF)
IF ( OSX_EMBEDDED_LIBRARY )
   SET(OSX_EMBEDDED_LIBRARY_FOLDER "PlugIns" CACHE STRING "The Name  
of the Folder within the *.app/Contents/ package." FORCE)
ENDIF ( OSX_EMBEDDED_LIBRARY )

IF ( OSX_EMBEDDED_LIBRARY )
   SET (OSX_CUSTOM_RPATH "@executable_path/../$ 
{OSX_EMBEDDED_LIBRARY_FOLDER}/")
   SET(CMAKE_C_CREATE_SHARED_LIBRARY
     "<CMAKE_C_COMPILER> <LANGUAGE_COMPILE_FLAGS>  
<CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> <LINK_FLAGS> -o <TARGET> - 
install_name ${OSX_CUSTOM_RPATH}<TARGET_SONAME> <OBJECTS>  
<LINK_LIBRARIES>")
   SET(CMAKE_CXX_CREATE_SHARED_LIBRARY
     "<CMAKE_CXX_COMPILER> <LANGUAGE_COMPILE_FLAGS>  
<CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <LINK_FLAGS> -o <TARGET> - 
install_name ${OSX_CUSTOM_RPATH}<TARGET_SONAME> <OBJECTS>  
<LINK_LIBRARIES>")
ELSE ( OSX_EMBEDDED_LIBRARY )
   SET(CMAKE_C_CREATE_SHARED_LIBRARY
     "<CMAKE_C_COMPILER> <LANGUAGE_COMPILE_FLAGS>  
<CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> <LINK_FLAGS> -o <TARGET> - 
install_name <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS>  
<LINK_LIBRARIES>")
   SET(CMAKE_CXX_CREATE_SHARED_LIBRARY
     "<CMAKE_CXX_COMPILER> <LANGUAGE_COMPILE_FLAGS>  
<CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <LINK_FLAGS> -o <TARGET> - 
install_name <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS>  
<LINK_LIBRARIES>")
ENDIF ( OSX_EMBEDDED_LIBRARY )
------------------------------------------


The variable names probably need some tweaking. And we could put  
allow the user to change the entire prefix including the  
"@executable_path" part also (I don't at the moment)

-- 
Mike Jackson   Senior Research Engineer
Innovative Management & Technology Services




More information about the vtkusers mailing list