[CMake] CMake, iOS and .xib compilation

Daniel Dekkers d.dekkers at cthrough.nl
Wed Sep 21 12:41:54 EDT 2011


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.

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.

Kind Regards,

Daniel Dekkers





More information about the CMake mailing list