View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0012288CMakeCMakepublic2011-06-20 03:572016-06-10 14:31
ReporterIvan Neeson 
Assigned ToKitware Robot 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionmoved 
PlatformMacOSOSXOS Version10.6
Product VersionCMake 2.8.4 
Target VersionFixed in Version 
Summary0012288: project/try_compile fails for XCode when CMAKE_OSX_SYSROOT is set to iPhone
DescriptionCMake 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 Reproducecmake_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 InformationTo 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 ..."
TagsNo tags attached.
Attached Fileslog file icon CMakeError.log [^] (622 bytes) 2011-06-20 03:57
patch file icon 0001-Quick-hack-to-allow-fixing-up-of-try_compile-targets.patch [^] (1,658 bytes) 2013-02-04 15:39 [Show Content]
patch file icon 0001-Fix-try_compile-and-try_run-on-IOS.patch [^] (1,862 bytes) 2013-02-06 20:54 [Show Content]

 Relationships
duplicate of 0015329closed try_compile fails for iOS targets 

  Notes
(0030312)
David Cole (manager)
2012-08-11 11:38

Sending old, never assigned issues to the backlog.

(The age of the bug, plus the fact that it's never been assigned to anyone means that nobody is actively working on it...)

If an issue you care about is sent to the backlog when you feel it should have been addressed in a different manner, please bring it up on the CMake mailing list for discussion. Sign up for the mailing list here, if you're not already on it: http://www.cmake.org/mailman/listinfo/cmake [^]

It's easy to re-activate a bug here if you can find a CMake developer who has the bandwidth to take it on, and ferry a fix through to our 'next' branch for dashboard testing.
(0032146)
Remo Eichenberger (reporter)
2013-01-24 07:40
edited on: 2013-01-24 07:51

I have this issue also with MacOSX 10.8, iOS 6, and CMake2.8.10.2 .

It should be possible to add commands at:

cmCoreTryCompile::TryCompileCode

like that what "Ivan Neeson" has written.
Without this, it is not possible to run compiler checks for iOS.

Here are others:

http://code.google.com/p/ios-cmake/issues/detail?id=1 [^]
http://forum.openscenegraph.org/viewtopic.php?t=8957 [^]
http://forum.openscenegraph.org/viewtopic.php?t=8810 [^]
http://forum.openscenegraph.org/viewtopic.php?t=8012 [^]

(0032192)
David Brady (reporter)
2013-02-04 15:43

I've attached a patch that allows you to write arbitrary code inside of the try_compile CMakeLists.txt.

It's kind of rough though. I think it should pass in the target name into a function passed in, but unfortunately I can't figure out how to get it into the scope of the try_compile CMakeLists.txt. So the arbitrary code will have to access the try_compile target by the CMAKE_TRY_COMPILE_TARGET variable.
(0032193)
David Brady (reporter)
2013-02-04 15:50

And a sample of how to use this hack:

set(CMAKE_TRY_COMPILE_FIXUP "MESSAGE(\"\${CMAKE_TRY_COMPILE_TARGET} is compiling\")")
(0032207)
David Brady (reporter)
2013-02-06 20:57

I've attached one more patch to get try_run working on IOS as well. The compiled .app isn't really valid from a try_compile, and try_run doesn't like that it can't find the executable. I don't think it's really relevant that the .app is invalid, since we are cross-compiling. So the second patch ignores the lack of an executable if we are cross-compiling, and handles the try_run anyway.
(0034949)
Piotr Wach (reporter)
2014-01-16 05:24

I have the same problem. I have modified cmake sources to add commands mentioned by Ivan to try_compile CMakeList.txt and it worked.

We use try_compile a lot in our project, and because it does not work for iOS, we are not able to generate working Xcode project file.

Is there any estimate when this can be fixed?
(0041852)
Kitware Robot (administrator)
2016-06-10 14:28

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 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
2012-08-11 11:38 David Cole Status new => backlog
2012-08-11 11:38 David Cole Note Added: 0030312
2013-01-24 07:40 Remo Eichenberger Note Added: 0032146
2013-01-24 07:43 Remo Eichenberger Note Edited: 0032146
2013-01-24 07:51 Remo Eichenberger Note Edited: 0032146
2013-02-04 15:39 David Brady File Added: 0001-Quick-hack-to-allow-fixing-up-of-try_compile-targets.patch
2013-02-04 15:43 David Brady Note Added: 0032192
2013-02-04 15:50 David Brady Note Added: 0032193
2013-02-06 20:54 David Brady File Added: 0001-Fix-try_compile-and-try_run-on-IOS.patch
2013-02-06 20:57 David Brady Note Added: 0032207
2014-01-16 05:24 Piotr Wach Note Added: 0034949
2015-08-11 10:40 Gregor Jasny Relationship added duplicate of 0015329
2016-06-10 14:28 Kitware Robot Note Added: 0041852
2016-06-10 14:28 Kitware Robot Status backlog => resolved
2016-06-10 14:28 Kitware Robot Resolution open => moved
2016-06-10 14:28 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team