Add IOS_DEPLOYMENT_TARGET variable to iOS.cmake - Gives an option to specify a lower deployment target version than the current SDK for backward compatibility. Change-Id: Ieb84ba7f42cdf925510f84b8e0cd01b5e9fc051b
diff --git a/CMakeLists.txt b/CMakeLists.txt index 8581b4c..fc366c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -148,9 +148,9 @@ message(STATUS "Building Ceres for iOS platform: ${IOS_PLATFORM}") # Ceres requires at least iOS 7.0+. - if (IOS_SDK_VERSION VERSION_LESS 7.0) - message(FATAL_ERROR "Unsupported iOS SDK version: ${IOS_SDK_VERSION}, Ceres " - "required at least iOS version 7.0") + if (IOS_DEPLOYMENT_TARGET VERSION_LESS 7.0) + message(FATAL_ERROR "Unsupported iOS version: ${IOS_DEPLOYMENT_TARGET}, Ceres " + "requires at least iOS version 7.0") endif() update_cache_variable(MINIGLOG ON)
diff --git a/cmake/iOS.cmake b/cmake/iOS.cmake index 23fe920..8d34d61 100644 --- a/cmake/iOS.cmake +++ b/cmake/iOS.cmake
@@ -222,22 +222,29 @@ set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}") set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}") -# Specify minimum version as latest SDK version. Note that only Xcode 7+ -# supports the newer more specific: -m${XCODE_IOS_PLATFORM}-version-min flags, -# older versions of Xcode use: -m(ios/ios-simulator)-version-min instead. +# Specify minimum version of deployment target. +# Unless specified, the latest SDK version is used by default. +set(IOS_DEPLOYMENT_TARGET "${IOS_SDK_VERSION}" + CACHE STRING "Minimum iOS version to build for." ) +message(STATUS "Building for minimum iOS version: ${IOS_DEPLOYMENT_TARGET}" + " (SDK version: ${IOS_SDK_VERSION})") + +# Note that only Xcode 7+ supports the newer more specific: +# -m${XCODE_IOS_PLATFORM}-version-min flags, older versions of Xcode use: +# -m(ios/ios-simulator)-version-min instead. if (XCODE_VERSION VERSION_LESS 7.0) if (IOS_PLATFORM STREQUAL "OS") set(XCODE_IOS_PLATFORM_VERSION_FLAGS - "-mios-version-min=${IOS_SDK_VERSION}") + "-mios-version-min=${IOS_DEPLOYMENT_TARGET}") else() # SIMULATOR or SIMULATOR64 both use -mios-simulator-version-min. set(XCODE_IOS_PLATFORM_VERSION_FLAGS - "-mios-simulator-version-min=${IOS_SDK_VERSION}") + "-mios-simulator-version-min=${IOS_DEPLOYMENT_TARGET}") endif() else() # Xcode 7.0+ uses flags we can build directly from XCODE_IOS_PLATFORM. set(XCODE_IOS_PLATFORM_VERSION_FLAGS - "-m${XCODE_IOS_PLATFORM}-version-min=${IOS_SDK_VERSION}") + "-m${XCODE_IOS_PLATFORM}-version-min=${IOS_DEPLOYMENT_TARGET}") endif() set(CMAKE_C_FLAGS