The iOS product type 'com.apple.package-type.bundle.unit-test' requires
code signing on Xcode 6. Other iOS target types do too. Until CMake
learns to add the CODE_SIGN_IDENTITY build attribute itself, toolchain
files can set CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY to tell the Xcode
generator to add the attribute. Teach CMakeDetermineCompilerId to
recognize this variable and add the CODE_SIGN_IDENTITY build attribute
to the compiler id project.
Since commit 0cce556b (Xcode: Use sysroot and deployment target to
identify compiler, 2014-04-29) our compiler id detection project uses
the target platform SDK in case Xcode selects a different compiler based
on it. Now the compiler id project actually compiles with the target
compiler and SDK when cross-compiling.
The iOS tools do not support the 'com.apple.product-type.tool' product
type we use in our compiler id detection project. When targeting
iPhone, use product type 'com.apple.product-type.bundle.unit-test'
instead.
Use CMAKE_OSX_SYSROOT and CMAKE_OSX_DEPLOYMENT_TARGET to set the Xcode
SDKROOT and MACOSX_DEPLOYMENT_TARGET build settings. This is necessary
because some versions of Xcode select a different compiler based on
these settings. We need to make sure the compiler identified during
language initialization matches what will be used for the actual build.
Configure a hand-generated Xcode project to build the compiler id source
file since we cannot run the compiler command-line tool directly. Add a
post-build shell script phase to print out the compiler toolset build
setting. Run xcodebuild to compile the identification binary. Parse
the full path to the compiler tool from the xcodebuild output.