[CMake] How to set sensible Universal Binary options in OS X by default

Bill Hoffman bill.hoffman at kitware.com
Tue Mar 13 14:35:40 EST 2007


E. Wing wrote:
> So I would like to set the Universal Binary options as the default for
> my project when on Apple. The issue is the options need to be
> different for different versions of OS X.
> In 10.4, I want to build ppc;i386. The SDK path must be set to 10.4u.
> In 10.5, I want to build ppc;i386;ppc64;x86_64. I'm presuming the SDK
> path should be set to a 10.5 thing.
> In 10.3 and lower, Universal Binaries can't be built so none of this 
> applies.
>
> Is there an elegant way to do this? My not so elegant solution/thought
> is to check OS X version numbers and case the thing. But how can I
> detect the OS version number with CMake? The Darwin version number
> isn't reliable for this case since Darwin may be upgraded
> independently of the OS X version. (There is a corner case too where
> it would help to know the Xcode version installed. 2.0 didn't have
> Universal Binary support; the support was introduced in 2.1. But I
> might not worry about this case if it's too hard.)
>
> (It would be kind of nice if CMake would automatically pick these
> defaults on the appropriate system. It's easier to for a user to
> delete the options than figure out what the appropriate switches are.)
The current approach is to detect the SDK path on the machine.
If 10.4u is on the machine then put the variable OSX_ARCHS in
the cache, if not then it must be an older xcode or OS.  You could
do the same thing with your project.  IF(EXISTS ...)

-Bill




More information about the CMake mailing list