[CMake] IPhone SDK and Frameworks

Clemens Arth clemens.arth at gmx.at
Fri Oct 16 03:22:00 EDT 2009


Hi,

I know this topic comes up now and then, but I could not find a
sufficiently documented solution to this issue yet. I still think the
know-how must be out there. I wanted to set up a project to build on the
iPhone or the iPhone simulator with XCode. What I found to be most
informative are these two postings:

http://stackoverflow.com/questions/794137/how-to-set-up-cmake-to-build-a-library-for-the-iphone
http://stackoverflow.com/questions/822404/how-to-set-up-cmake-to-build-an-app-for-the-iphone

There are two issues I came up right at the start:

1) Not setting CMAKE_OSX_SYSROOT results in building the project for the
current desktop OS, but if you set it, it must point to a valid SDK
directory (e,g.
/Developer/Platform/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.1.sdk)
- then it creates a iPhone project, where you can select basically any
SDK, and it seems that XCode handles the SDKs automatically, as Visual
Studio does it for Windows Mobile 5/6 a.s.o.. So far, so good. BUT:

2) I know that CMake is framework aware, it still seems to be tricky to
add frameworks to the projects in a generic way. I tried to use
FIND_LIBRARY but it did not work out as expected, because it only found
the desktop os libraries. So I fixed it using something like:

SET(TARGETSDK iPhoneSimulator3.1.sdk)
SET(CMAKE_OSX_SYSROOT
/Developer/Platform/iPhoneSimulator.platform/Developer/SDKs/${TARGETSDK})
SET(CMAKE_OSX_ARCHITECTURES ${ARCH_STANDARD_32_BIT})

FIND_LIBRARY(OPENGLES NAMES OpenGLES PATHS ${CMAKE_OSX_SYSROOT
}/System/Library PATH_SUFFIXES Frameworks NO_DEFAULT_PATH)
MARK_AS_ADVANCED(OPENGLES )
TARGET_LINK_LIBRARIES(MyApp ${OPENGLES})

and then if finds the SDK, but only for the iPhoneSimulator3.1.sdk. I
don't think it takes the right SDK if I switch to the 3.1.2 SDK in
XCode. Basically the question rises, if there is a way to add the
Framework as is into Xcode without passing an exact path to it.

Any comments are highly appreciated...
Regards...






More information about the CMake mailing list