MantisBT - CMake
View Issue Details
0012288CMakeCMakepublic2011-06-20 03:572016-06-10 14:31
Ivan Neeson 
Kitware Robot 
normalmajoralways
closedmoved 
MacOSX10.6
CMake 2.8.4 
 
0012288: project/try_compile fails for XCode when CMAKE_OSX_SYSROOT is set to iPhone
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.
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)
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 ..."
No tags attached.
duplicate of 0015329closed  try_compile fails for iOS targets 
log CMakeError.log (622) 2011-06-20 03:57
https://public.kitware.com/Bug/file/3950/CMakeError.log
patch 0001-Quick-hack-to-allow-fixing-up-of-try_compile-targets.patch (1,658) 2013-02-04 15:39
https://public.kitware.com/Bug/file/4633/0001-Quick-hack-to-allow-fixing-up-of-try_compile-targets.patch
patch 0001-Fix-try_compile-and-try_run-on-IOS.patch (1,862) 2013-02-06 20:54
https://public.kitware.com/Bug/file/4636/0001-Fix-try_compile-and-try_run-on-IOS.patch
Issue History
2011-06-20 03:57Ivan NeesonNew Issue
2011-06-20 03:57Ivan NeesonFile Added: CMakeError.log
2012-08-11 11:38David ColeStatusnew => backlog
2012-08-11 11:38David ColeNote Added: 0030312
2013-01-24 07:40Remo EichenbergerNote Added: 0032146
2013-01-24 07:43Remo EichenbergerNote Edited: 0032146bug_revision_view_page.php?bugnote_id=32146#r1012
2013-01-24 07:51Remo EichenbergerNote Edited: 0032146bug_revision_view_page.php?bugnote_id=32146#r1013
2013-02-04 15:39David BradyFile Added: 0001-Quick-hack-to-allow-fixing-up-of-try_compile-targets.patch
2013-02-04 15:43David BradyNote Added: 0032192
2013-02-04 15:50David BradyNote Added: 0032193
2013-02-06 20:54David BradyFile Added: 0001-Fix-try_compile-and-try_run-on-IOS.patch
2013-02-06 20:57David BradyNote Added: 0032207
2014-01-16 05:24Piotr WachNote Added: 0034949
2015-08-11 10:40Gregor JasnyRelationship addedduplicate of 0015329
2016-06-10 14:28Kitware RobotNote Added: 0041852
2016-06-10 14:28Kitware RobotStatusbacklog => resolved
2016-06-10 14:28Kitware RobotResolutionopen => moved
2016-06-10 14:28Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0030312)
David Cole   
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   
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   
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   
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   
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   
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   
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.