Compiling for iOS with CMake

I've been using an updated version of the iOS CMake toolchain for quite a while: https://github.com/leetal/ios-cmake

This creates an Xcode project which you can drag into an existing iOS project if necessary.

I wrote a blog post with more details: https://blog.tomtasche.at/2019/05/how-to-include-cmake-project-in-xcode.html


Just use this toolchain file: http://code.google.com/p/ios-cmake/ and use it as

cmake -DCMAKE_TOOLCHAIN_FILE=path_to_your_toolchain_file

Then, in CMakeLists.txt:

SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch armv7")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch armv7")

By following cmake-toolchains documentation I did like below:

cmake -G Xcode -B build \
    -DCMAKE_SYSTEM_NAME=iOS \
    -DCMAKE_Swift_COMPILER_FORCED=true \
    -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0

Note: That assignment CMAKE_OSX_DEPLOYMENT_TARGET=11.0 is not a mistake when targeting iOS.