This is closely related to my previous question, which was about using CMake to build a static library on the iPhone. I got that to work setting the CMAKE_OSX_SYSROOT
.
However, this doesn't work to build an app. My CMakeLists.txt
looks like:
project(TEST)
set(CMAKE_OSX_SYSROOT iphoneos2.2.1)
set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_BIT)")
set(CMAKE_EXE_LINKER_FLAGS
"-framework Foundation -framework OpenGLES -framework AudioToolbox -framework CoreGraphics -framework QuartzCore -framework UIKit -framework OpenAL"
)
set(SRC --my files--)
add_executable(iphone-test MACOSX_BUNDLE ${SRC})
A few notes:
- I'm explicitly giving the
-framework
linking option becausefind_library
didn't work for all of the frameworks (it found most of them, but notOpenGLES
). I don't understand why, since they're all in the same folder${SDK}/System/Library/Frameworks
. This leads me to believe that I was doing something wrong, but I don't know what. - I added
MACOSX_BUNDLE
to theadd_executable
command so that the product type generated would becom.apple.product-type.application
instead ofcom.apple.product-type.tool
, which apparently doesn't exist on the iPhone.
In any case, the app compiles and links correctly, but when I run it in the simulator, I get the dreaded
Failed to launch simulated application: Unknown error.
There are lots of reported instances of this problem on google and stackoverflow, but all of the solutions involve cleaning up or creating a new project and moving files; but I'm compiling a fresh copy after CMake does its work, so none of that applies.
I found this thread on the CMake mailing list, but it only reports a success in building a library, and then peters out.