MantisBT - CMake
View Issue Details
0015329CMakeCMakepublic2014-12-28 06:352016-01-04 11:52
Egor P. 
 
normalminoralways
closedfixed 
OS X10.10.1
CMake 3.1 
CMake 3.2 
0015329: try_compile fails for iOS targets
This is related to:
http://www.cmake.org/Bug/view.php?id=15214 [^]

When crosscompiling for iOS I see an error:
Check dependencies
target specifies product type 'com.apple.product-type.tool', but there's no such product type for the 'iphoneos' platform

This is during configure stage.

In that ticket above you mentioned two commits:
http://www.cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c48f6e12 [^]
http://www.cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b91020f6 [^]

The fix to id_product_type is related for some "...bundle.unit-test".

+ set(id_product_type "com.apple.product-type.tool")
     if(CMAKE_OSX_SYSROOT)
       set(id_sdkroot "SDKROOT = \"${CMAKE_OSX_SYSROOT}\";")
+ if(CMAKE_OSX_SYSROOT MATCHES "(^|/)[Ii][Pp][Hh][Oo][Nn][Ee]")
+ set(id_product_type "com.apple.product-type.bundle.unit-test")
+ endif()

At the second commit related to code signing we see:

+ if(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY)
+ set(id_code_sign_identity "CODE_SIGN_IDENTITY = \"${CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY}\";")
+ else()
+ set(id_code_sign_identity "")
+ endif()

Can you please add such switch to id_product_type?
E.g.:
if(CMAKE_XCODE_ATTRIBUTE_ID_PRODUCT_TYPE)
  set(id_product_type "ID_PRODUCT_TYPE = \"${CMAKE_XCODE_ATTRIBUTE_ID_PRODUCT_TYPE}\";")
else()
  ........
endif()

I'm asking this because I found the next page with different possible product types:
https://github.com/freewizard/Xcode-Template-iOS-dylib/blob/master/Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/Specifications/iPhone%20Simulator%20ProductTypes.xcspec [^]
And when I set PRODUCT_TYPE = com.apple.product-type.application in Xcode manually, the build works.
No tags attached.
related to 0015214closed Brad King Error getting iOS compiler identification on master 
has duplicate 0012288closed Kitware Robot project/try_compile fails for XCode when CMAKE_OSX_SYSROOT is set to iPhone 
Issue History
2014-12-28 06:35Egor P.New Issue
2014-12-28 06:40Egor P.Note Added: 0037533
2014-12-28 06:58Egor P.Note Added: 0037534
2014-12-28 07:06Egor P.Note Added: 0037535
2014-12-28 08:34Egor P.Note Added: 0037537
2014-12-28 08:34Egor P.Note Edited: 0037537bug_revision_view_page.php?bugnote_id=37537#r1666
2015-01-08 11:53Brad KingTarget Version => CMake 3.2
2015-01-08 11:53Brad KingSummaryCannot set CMAKE_XCODE_ATTRIBUTE_ID_PRODUCT_TYPE manually => try_compile fails for iOS targets
2015-01-08 11:55Brad KingNote Added: 0037632
2015-01-11 15:45Brad KingRelationship addedrelated to 0015214
2015-01-19 10:16Brad KingStatusnew => backlog
2015-01-19 10:16Brad KingTarget VersionCMake 3.2 =>
2015-01-19 10:20Brad KingNote Added: 0037737
2015-01-27 09:30Egor P.Note Added: 0037836
2015-01-31 09:57Egor P.Note Added: 0037871
2015-03-18 15:09Gregor JasnyNote Added: 0038242
2015-03-18 17:33Egor P.Note Added: 0038248
2015-03-18 17:34Egor P.Note Edited: 0038248bug_revision_view_page.php?bugnote_id=38248#r1732
2015-03-18 17:34Egor P.Note Edited: 0038248bug_revision_view_page.php?bugnote_id=38248#r1733
2015-03-19 08:21Brad KingStatusbacklog => resolved
2015-03-19 08:21Brad KingResolutionopen => fixed
2015-03-19 08:21Brad KingFixed in Version => CMake 3.2
2015-08-11 10:40Gregor JasnyRelationship addedhas duplicate 0012288
2016-01-04 11:52Robert MaynardNote Added: 0040112
2016-01-04 11:52Robert MaynardStatusresolved => closed

Notes
(0037533)
Egor P.   
2014-12-28 06:40   
I wrote 'ID_PRODUCT_TYPE' and 'CMAKE_XCODE_ATTRIBUTE_ID_PRODUCT_TYPE' in the ticket description because you write this in commit:
--- a/Modules/CompilerId/Xcode-3.pbxproj.in
- productType = "com.apple.product-type.tool";
+ productType = "@id_product_type@";

Of course, it probably should be just 'PRODUCT_TYPE' and 'CMAKE_XCODE_ATTRIBUTE_PRODUCT_TYPE'.
(0037534)
Egor P.   
2014-12-28 06:58   
In other words, we need a way to set 'PRODUCT_TYPE' for all target including 'try_compile' steps.
'PRODUCT_TYPE = com.apple.product-type.application' helps (this was set manually in Xcode).
But I still cannot find when CMake sets it to 'com.apple.product-type.tool'.
I changed code in 'Modules/CMakeDetermineCompilerId.cmake' - this did not work.
(0037535)
Egor P.   
2014-12-28 07:06   
More notes. :)

'com.apple.product-type.tool' is set in cmGlobalXCodeGenerator.cxx:
case cmTarget::EXECUTABLE:
      return (cmtarget.GetPropertyAsBool("MACOSX_BUNDLE")?
              "com.apple.product-type.application" :
              "com.apple.product-type.tool");

But MACOSX_BUNDLE requires code signing.
I'm trying to skip this step at the moment for some reasons.

set(CMAKE_MACOSX_BUNDLE YES)
gives
CodeSign error: code signing is required for product type 'Application' in SDK 'iOS 8.1'

I used next commands and it works till some steps:
set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.example")
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "Don't Code Sign")

But again I'm trying to skip codesign for now.
(0037537)
Egor P.   
2014-12-28 08:34   
Ok, updating.

I set in code in cmGlobalXCodeGenerator.cxx:
case cmTarget::EXECUTABLE:
      return "com.apple.product-type.application";
just for testing purposes.

So, we build "com.apple.product-type.application" without MACOSX_BUNDLE.
Next it required code signing. I wrote:
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")

And it helps, configure steps are passing perfect now.

Without my changes configure steps like 'check_type_size', 'test_big_endian', 'check_c_source_compiles' were not passing. Now they are working fine.

(0037632)
Brad King   
2015-01-08 11:55   
I think try_compile needs to be taught to use CODE_SIGNING_REQUIRED == NO and a valid product type for iOS out of the box.
(0037737)
Brad King   
2015-01-19 10:20   
As mentioned in 0015214:0037669 the code signing requirement has now been dropped for the compiler identification step which uses "Modules/CompilerId/Xcode-3.pbxproj.in" to bootstrap before enough information is available for the full Xcode generator.

The try_compile command is separate and actually uses the C++-implemented Xcode generator, so that would need to be taught how to do this as mentioned in 0015329:0037632. For now IIUC the workaround is

 set(CMAKE_MACOSX_BUNDLE YES)
 set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")

in the toolchain file.
(0037836)
Egor P.   
2015-01-27 09:30   
No, it is not.

Unpached cmake produces always the error below during iOS crosscompiling. (Remember that this is the latest build environment: latest OS X, Xcode, iOS, command line tools).
It seems it's because of wrong product type.

Error:
Check dependencies
target specifies product type 'com.apple.product-type.tool', but there's no such product type for the 'iphoneos' platform

It is not possible to find headers (CheckIncludeFiles), functions (CheckFunctionsExists), CodeCompiles, CodeRuns etc. <- Every linking stage is rejected by Xcode linker.
(0037871)
Egor P.   
2015-01-31 09:57   
Does not work with 3.1.1 version.
Still wrong product type.
(0038242)
Gregor Jasny   
2015-03-18 15:09   
Setting

set(CMAKE_MACOSX_BUNDLE YES)

in the toolchain file works for me with v3.2.1-440-g380db3d. Did you set it in the toolchain file?
(0038248)
Egor P.   
2015-03-18 17:33   
(edited on: 2015-03-18 17:34)
It works now (CMake 3.2.1).
The ticket should be marked as resolved.

The successful sequence in toolchain file is:
set(CMAKE_MACOSX_BUNDLE YES)
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")

(0040112)
Robert Maynard   
2016-01-04 11:52   
Closing resolved issues that have not been updated in more than 4 months.