Skip to content

Support for iOS cross compiling using cmake 3.14+ #87

Open
@kylefleming

Description

@kylefleming

As of version 3.14, cmake has added support for cross compiling iOS (see https://cmake.org/cmake/help/latest/release/3.14.html?highlight=cross#platforms).

This means that -miphone-version-min style parameters get added automatically. This also means that currently when using cmake-rs, these parameters are being added twice, and often with conflicting values.

I've found that in order the support the new system, the following CMAKE variables need to be set:

  • CMAKE_SYSTEM_NAME (Set to iOS)
  • CMAKE_OSX_ARCHITECTURES (Set to one of: arm64, armv7, armv7s, i386, or x86_64)
  • CMAKE_OSX_DEPLOYMENT_TARGET (Could likely be pulled from the IPHONEOS_DEPLOYMENT_TARGET env variable)
  • CMAKE_OSX_SYSROOT (Set to either: iphoneos or iphonesimulator)

The target triplets for iOS are:

  • aarch64-apple-ios
  • armv7-apple-ios
  • armv7s-apple-ios
  • i386-apple-ios
  • x86_64-apple-ios

Additionally, I found that cmake-rs (via cc-rs) is setting the following compiler flags which are not added by cmake:

  • -fPIC
  • -fembed-bitcode

Note: cmake 3.14 also added support for tvOS and watchOS, but since I don't support them in my own app, I don't know what's required to support them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions