[CMake] CMake, iOS and .xib compilation

David Cole david.cole at kitware.com
Sat Oct 1 13:11:06 EDT 2011


On Fri, Sep 23, 2011 at 10:17 AM, Daniel Dekkers <d.dekkers at cthrough.nl>wrote:

> Hi David,
>
> I'm looking at your iOSNavApp test for iOS.
>
> A few comments as of now:
>
> - universal -
>
> NavApp3 is an iPhone build, if you run it on an iPad (or iPad simulator) it
> "emulates" an iPhone on screen.
> I've made my version of your test "universal" (as in.. iPad and iPhone) by
> just adding an extra target property: XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY
> '1,2'
>
>
Nice. I'll consider doing that for NavApp3, too, if it's easy enough to
achieve an "iPad look" to that app. I'll put that on my list of stuff to
consider moving forward.


- .xib compilation -
>
> I finally understand why your .xib files are compiled correctly, while
> apparently just adding them to add_excutable().
> It's the RESOURCE "${RESOURCES}" target property. That makes Xcode
> "resource aware".
>

Yes.



>
> - architectures -
>
> You explicitly set the CMAKE_OSX_ARCHITECTURE to "armv6;armv7;i386", which
> makes sense. Older devices, newer devices and simulator.
> And you set CMAKE_XCODE_EFFECTIVE_PLATFORMS to "-iphoneos;-iphonesimulator"
>
> Which results in:
>
> Architectures: armv6 armv7 i386
> Build Active Architecture Only: No
> Supported Platforms: iphonesimulator iphoneos
> Valid Architectures: armv6 armv7
>
> In my projects until now i've been using $(ARCHS_UNIVERSAL_IPHONE_OS) for
> CMAKE_OSX_ARCHITECTURES, ignoring the CMAKE_XCODE_EFFECTIVE_PLATFORMS
> resulting in:
>
> Architectures: Optimized (armv7)
> Build Active Architecture Only: No
> Supported Platforms: iphonesimulator iphoneos
> Valid Architectures: armv6 armv7
>
> And it still runs on both devices and simulators. Bit strange.
>

Hmm. So both approaches work? I'll have to analyze further to understand
why.



>
> - artwork (icons/splashscreens/) -
>
> Maybe the next step would be to add an icon.png?
>

Good idea. I'll add that to my list also.



>
> What are your plans with the iOSNavApp test?
>

- To be a reasonable iOS example for people to follow.
- To enable it on at least one, and possibly multiple, dashboard machines
that submit results nightly, to verify that this functionality keeps working
into the future.
- No other plans, but I'm open to suggestions


Cheers,
David C.




>
> Kind Regards,
> Daniel Dekkers
>
> On Sep 21, 2011, at 7:30 PM, David Cole wrote:
>
> > On Wed, Sep 21, 2011 at 12:41 PM, Daniel Dekkers <d.dekkers at cthrough.nl>
> wrote:
> >> Hi David,
> >>
> >>> I have tested it manually using the Xcode generator. The point of this
> >>> recent work was focused on getting "simulator" and "device" builds
> >>> both working within the same Xcode project at the same time, and
> >>> allowing the developer to switch back and forth between them in the
> >>> Xcode UI.
> >>>
> >>> There are *.xib files in this project, and they are included simply by
> >>> adding them as source files to add_executable.
> >>
> >> Ok, i've tried that and it works. But it seems I have to "label" the
> .xib files first...
> >>
> >>                SET_SOURCE_FILES_PROPERTIES(
> >>                        ${RSRC_IOS_XIB_FILES}
> >>                        PROPERTIES
> >>                        MACOSX_PACKAGE_LOCATION Resources
> >>                )
> >>
> >> ... otherwise Xcode just seems to ignore the file (although it makes it
> visible in the IDE).
> >> If i do "label" it, Xcode recognizes the file, compiles it and adds it
> to the bundle in the first steps of the build process.
> >> So i deleted my own Cmake .xib compilation script.
> >>
> >
> > Excellent -- good to know this was helpful.
> >
> >
> >> About the simulator and device builds... much to my surprise my
> toolchain file for device works for the simulator as well (both iPad and
> iPhone).
> >>
> >> It looks like this:
> >>
> >>        MESSAGE(STATUS "Parsing iphone-device toolchain file")
> >>        SET (CMAKE_SYSTEM_NAME Generic)
> >>        SET (CMAKE_SYSTEM_VERSION 1)
> >>        SET (CMAKE_SYSTEM_PROCESSOR arm)
> >>
> >>        SET (SDKVER "4.3")
> >>        SET (DEVROOT "/Developer/Platforms/iPhoneOS.platform/Developer")
> >>        SET (SDKROOT "${DEVROOT}/SDKs/iPhoneOS${SDKVER}.sdk")
> >>        SET (CMAKE_OSX_SYSROOT "${SDKROOT}")
> >>        SET (CMAKE_OSX_ARCHITECTURES "$(ARCHS_UNIVERSAL_IPHONE_OS)") #
> Either "$(ARCHS_UNIVERSAL_IPHONE_OS)" or "arm6" "arm7"
> >>
> >>        SET (CMAKE_C_COMPILER "${DEVROOT}/usr/bin/gcc-4.2")
> >>        SET (CMAKE_CXX_COMPILER "${DEVROOT}/usr/bin/g++-4.2")
> >>
> >>        SET (CMAKE_FIND_ROOT_PATH "${IPHONE_SDKROOT}"
> "/opt/iphone-${SDK_VER}/" "/usr/local/iphone-${SDK_VER}/")
> >>        SET (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
> >>        SET (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
> >>        SET (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
> >>
> >> I just include it at the moment. So i'm thinking to remove the
> simulator/device distinction altogether and just add these settings to the
> main CMakeLists.txt
> >> Although i do like the concept of cross-compiling and toolchain files
> very much. With future android builds and all.
> >>
> >
> > This is also good to know. I'd definitely recommend keeping that stuff
> > in the toolchain file rather than putting it directly in the
> > CMakeLists.txt file. One of these days I'm going to try out this
> > cross-compiling toolchain thing for my own personal edification... :-)
> >
> > Let us know if you run into any problems.
> >
> >
> > Thanks,
> > David
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111001/6c103e04/attachment.htm>


More information about the CMake mailing list