[CMake] [Q] Searching mailing list archive about swig-python-osx-bundle?

Bill Hoffman bill.hoffman at kitware.com
Sat Sep 8 22:26:46 EDT 2007


Sean McBride wrote:
> On 9/8/07 9:40 AM, Nicholas Yue said:
>
>   
>>  I'd like to search the mailing list archive of information on how to
>> construct a cmake file to build a swig python extension (as a bundle) on OS
>> X?
>>
>>  My current build (of the swig python extension) on Linux is linking and
>> running fine but on OS X, the same cmake configuration file builds it as a
>> shared library but my understanding is that it needs to be build as a
>> bundle. I have an old Makefile that does that but I am hoping to migrate my
>> builds to use only CMake as it gives me much more flexibility and much less
>> maintanance.
>>     
>
> I've never actually tried, but this should be a good start:
>
> IF(APPLE)
>   SET(EXECUTABLE_FLAG MACOSX_BUNDLE)
> ENDIF(APPLE)
>
>   

ADD_LIBRARY(foo MODULE) maybe all you need.   I am not sure why you 
think you need
a bundle.  An application bundle on a mac is an executable that has a 
gui.   A framework is the
same sort of thing but is really a shared library.   However, if you 
want to create a loadable module
on the mac, it is a done with the MODULE key word in CMake.   Basically 
shared libraries come
in 3 types on the mac:

1. a .dylib, this is about the same as a .so on linux/unix or a .dll on 
windows, except you can
not load it at run time, it is only for linking.

2. a framework, this is about the same as 1, except it also contains 
header files and other resources
bundled with the shared library.

3. a loadable module.  This is a shared module that can be loaded at run 
time, but it can not
be linked to like a .dylib.

For swig, you want 3.  And, you do not need an if(APPLE) in the cmake 
code since a MODULE
in cmake will be a .so, .dll, or mac module depending on the platform.

-Bill



More information about the CMake mailing list