[CMake] iOS multi-arch library target and xcodebuild

Jason Cooper cmake at lakedaemon.net
Thu Apr 2 08:15:39 EDT 2015


Parag,

On Wed, Apr 01, 2015 at 05:43:25PM +0000, Parag Chandra wrote:
> You need to cross-compile in order to target iOS, but if I?m reading your
> command line correctly, you are merely instructing CMake to generate an
> Xcode build system for the host OS, which is naturally going to produce a
> project that targets Mac OSX.

I never said I was on the *right* path. ;-)

> The normal way to cross-compile with CMake is to feed it a toolchain file,
> via the CMAKE_TOOLCHAIN_FILE cmd line option. You may want to take a look at
> the following project to get an iOS toolchain file from which to start:
> 
> https://code.google.com/p/ios-cmake/source/browse/toolchain/iOS.cmake

Ok, I had run into that before, but reasoned that the presence of
Tests/iOSNavApp/ meant there was now a way to accomplish my goal without
having to add what essentially looks like a cmake module.

Is there a plan to merge the above into cmake as a module?

> You can of course do something similar for Android:
> 
> https://github.com/taka-no-me/android-cmake/blob/master/android.toolchain.cmake

Ah, thanks for the heads up.  I'll need that later.

Back to the iOS.cmake.  I was able to get it to successfully build the
library dylib by adding the following lines to the same file:

# don't need code-signing on libs
set(CMAKE_MACOSX_BUNDLE YES)
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")

It's only armv7, so not universal.  But I can use lipo to work around
that.

This all seems rather complicated and fragile, though.  I wonder if it
might be simpler to have cmake generate standard Unix Makefiles and then
use a modified version of the openssl build script.

thx,

Jason.


More information about the CMake mailing list