[CMake] [EXTERNAL]: Up to date iOS instructions

Parag Chandra parag at ionicsecurity.com
Mon Jan 9 12:00:47 EST 2017


Hi Harry,

I’m not sure about any official instructions, but here’s how I’m doing it:

# Adapted from https://code.google.com/p/ios-cmake/

# Standard settings
set (CMAKE_SYSTEM_NAME Darwin)
set (CMAKE_SYSTEM_VERSION 1)
set (UNIX True)
set (APPLE True)
set (IOS True)

# Required as of cmake 2.8.10
set (CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING "Force unset of the deployment target for iOS" FORCE)

# Figure out where Xcode is installed
execute_process (COMMAND "xcode-select" "--print-path" OUTPUT_VARIABLE CMAKE_XCODE_ROOT OUTPUT_STRIP_TRAILING_WHITESPACE)
set (CMAKE_XCODE_ROOT ${CMAKE_XCODE_ROOT} CACHE PATH "Location of Xcode. Normally auto-detected via 'xcode-select', but can be overridden")

# Skip the platform compiler checks for cross compiling
set (CMAKE_CXX_COMPILER_WORKS TRUE)
set (CMAKE_C_COMPILER_WORKS TRUE)

# Setup iOS platform unless specified manually with DEVICE_OR_SIMULATOR
if (NOT DEFINED DEVICE_OR_SIMULATOR)
    set (DEVICE_OR_SIMULATOR "OS")
endif ()
set (DEVICE_OR_SIMULATOR ${DEVICE_OR_SIMULATOR} CACHE STRING "Set to 'Simulator' (for simulators), or 'OS' (for devices)")

# Check the platform selection and setup for developer root
if (NOT((${DEVICE_OR_SIMULATOR} STREQUAL "OS") OR (${DEVICE_OR_SIMULATOR} STREQUAL "Simulator")))
    message (FATAL_ERROR "Unsupported DEVICE_OR_SIMULATOR value selected. Please choose 'OS' or 'Simulator'")
endif ()

set (CMAKE_IOS_DEVELOPER_ROOT "${CMAKE_XCODE_ROOT}/Platforms/iPhone${DEVICE_OR_SIMULATOR}.platform/Developer")

# Find and use the most recent iOS sdk unless specified manually with CMAKE_IOS_SDK_ROOT
if (NOT DEFINED CMAKE_IOS_SDK_ROOT)
    file (GLOB _CMAKE_IOS_SDKS "${CMAKE_IOS_DEVELOPER_ROOT}/SDKs/*")
    if (_CMAKE_IOS_SDKS)
        list (SORT _CMAKE_IOS_SDKS)
        list (REVERSE _CMAKE_IOS_SDKS)
        list (GET _CMAKE_IOS_SDKS 0 CMAKE_IOS_SDK_ROOT)
    else ()
        message (FATAL_ERROR "No iOS SDK's found in default search path ${CMAKE_IOS_DEVELOPER_ROOT}. Manually set CMAKE_IOS_SDK_ROOT or install the iOS SDK.")
    endif ()
    message (STATUS "Toolchain using default iOS SDK: ${CMAKE_IOS_SDK_ROOT}")
endif ()
set (CMAKE_IOS_SDK_ROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Location of the selected iOS SDK")

set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator")

# Set the sysroot default to the most recent SDK
# If we're generating Xcode projects, the keyword "iphoneos" is all that's needed; otherwise
# we need to specify the complete path
if (${CMAKE_GENERATOR} STREQUAL "Xcode")
    set (CMAKE_OSX_SYSROOT "iphoneos")
else ()
    # set (CMAKE_OSX_SYSROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support")
    # Actually, just fail - we haven't yet done the work to support any generator except Xcode for iOS
    message (FATAL_ERROR "Only the Xcode generator is supported at this time. Be sure to specify '-GXcode' on the cmd line.")
endif ()

# Set the find root to the iOS developer roots and to user defined paths
set (CMAKE_FIND_ROOT_PATH "${CMAKE_XCODE_ROOT}/Toolchains/XcodeDefault.xctoolchain/usr/bin" ${CMAKE_IOS_DEVELOPER_ROOT} ${CMAKE_IOS_SDK_ROOT} ${CMAKE_PREFIX_PATH} CACHE string  "iOS find search path root")

# default to searching for frameworks first
set (CMAKE_FIND_FRAMEWORK FIRST)

# set up the default search directories for frameworks
set (CMAKE_SYSTEM_FRAMEWORK_PATH
    ${CMAKE_IOS_SDK_ROOT}/System/Library/Frameworks
    ${CMAKE_IOS_SDK_ROOT}/System/Library/PrivateFrameworks
    ${CMAKE_IOS_SDK_ROOT}/Developer/Library/Frameworks
)





Parag Chandra
Technical Lead, Mobile Team
Mobile: +1.919.824.1410

Ionic Security Inc.
1170 Peachtree St. NE STE 400, Atlanta, GA 30309




From: CMake <cmake-bounces at cmake.org> on behalf of Harry Mallon <Harry at codexdigital.com>
Date: Monday, January 9, 2017 at 6:54 AM
To: "cmake at cmake.org" <cmake at cmake.org>
Subject: [EXTERNAL]: [CMake] Up to date iOS instructions

Hello,

Are there any up to date instructions for doing iOS builds? There are load of tutorials going back many years on Google. I am using something based on this https://github.com/cristeab/ios-cmake as a toolchain file currently but I am seeing the ${EFFECTIVE_PLATFORM_NAME} generator expression problem mentioned here last year (https://cmake.org/pipermail/cmake/2016-March/063113.html). I have heard something about CMAKE_OSX_SYSROOT = iphoneos and maybe CMAKE_IOS_INSTALL_COMBINED?

Yours,
Harry

Harry Mallon

CODEX | Software Engineer

60 Poland Street | London | England | W1F 7NT

E harry at codexdigital.com<mailto:harry at codexdigital.com> | T +44 203 7000 989<callto:+44%20203%207000%20989>

Website<http://codex.online> | Facebook<https://www.facebook.com/codexdigital> | Twitter<http://twitter.com/codexdigital>

[http://codex.online/?action=asset&id=5B21DF7C-EC27-4199-852F-D596F5F28DA9]<http://codex.online>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170109/16bf0ae2/attachment-0001.html>


More information about the CMake mailing list