[cmake-developers] [CMake 0012288]: project/try_compile fails for XCode when CMAKE_OSX_SYSROOT is set to iPhone

Mantis Bug Tracker mantis at public.kitware.com
Mon Jun 20 03:57:22 EDT 2011


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=12288 
====================================================================== 
Reported By:                Ivan Neeson
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   12288
Category:                   CMake
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2011-06-20 03:57 EDT
Last Modified:              2011-06-20 03:57 EDT
====================================================================== 
Summary:                    project/try_compile fails for XCode when
CMAKE_OSX_SYSROOT is set to iPhone
Description: 
CMake will fail if CMAKE_OSX_SYSROOT is set to an iPhone SDK with the error:
"target specifies product type 'com.apple.product-type.tool', but there's no
such product type for the 'iphoneos' platform".

If you add the CMAKE_OSX_SYSROOT after the first project() command cmake will
continue, but it will fail if you ever want to use try_compile.

Steps to Reproduce: 
cmake_minimum_required (VERSION 2.6)

set (CMAKE_OSX_SYSROOT
"/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/" CACHE
PATH "" FORCE)
set (CMAKE_OSX_ARCHITECTURES "armv6")

set (CMAKE_C_FLAGS "-arch ${CMAKE_OSX_ARCHITECTURES} -isysroot
${CMAKE_OSX_SYSROOT} -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings"
CACHE STRING "" FORCE)
set (CMAKE_CXX_FLAGS "-arch ${CMAKE_OSX_ARCHITECTURES} -isysroot
${CMAKE_OSX_SYSROOT} -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings"
CACHE STRING "" FORCE)

set (CMAKE_AR "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar"
CACHE FILEPATH "" FORCE)
set (CMAKE_CXX_COMPILER
"/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++" CACHE FILEPATH ""
FORCE)
set (CMAKE_C_COMPILER
"/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc" CACHE FILEPATH ""
FORCE)
set (CMAKE_INSTALL_NAME_TOOL
"/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/install_name_tool"
CACHE FILEPATH "" FORCE)
set (CMAKE_LINKER "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ld"
CACHE FILEPATH "" FORCE)
set (CMAKE_NM "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/nm"
CACHE FILEPATH "" FORCE)
set (CMAKE_RANLIB
"/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib" CACHE FILEPATH
"" FORCE)
set (CMAKE_STRIP
"/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/strip" CACHE FILEPATH
"" FORCE)

project (Test)

Additional Information: 
To fix this two issues will need to be resolved:

- the try_compile cmTryCompileExec target will need to have the MACOSX_BUNDLE
target property set on it.
- the code-signing identity for the try_compile cmTryCompileExec target will
need to be set.

For a normal target, this can be done with:
set_target_properties (cmTryCompileExec PROPERTIES MACOSX_BUNDLE ON)
set_target_properties (cmTryCompileExec PROPERTIES
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer")

However this is not possible for the try_compile cmTryCompileExec target.

I think the best solution for this (and future related problems) would be the
addition of a feature to somehow allow users to modify the try_compile generated
CMakeLists.txt file. Either via the addition of a template or a "post-fix"
variable (eg CMAKE_TRY_COMPILE_POSTFIX="set_target_properties ..."

====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2011-06-20 03:57 Ivan Neeson    New Issue                                    
2011-06-20 03:57 Ivan Neeson    File Added: CMakeError.log                    
======================================================================




More information about the cmake-developers mailing list