View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0016084CMakeCMakepublic2016-04-27 06:412016-06-10 14:31
Reporterranjak 
Assigned ToKitware Robot 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionmoved 
PlatformiPhoneOSiOSOS Versionany
Product VersionCMake 3.5.2 
Target VersionFixed in Version 
Summary0016084: try_compile incorrect behavior for iOS universal build (device + simulator) with CMAKE_IOS_INSTALL_COMBINED
DescriptionWhen configuring an iOS Xcode project using CMAKE_IOS_INSTALL_COMBINED (introduced in CMake 3.5) to produce universal binaries that contain code for both iPhone (ARM) and simulator (x86) code, I would like try_compile to compile for both the device and the simulator. However, currently, try_compile only compiles for the device.

This causes projects that rely on try_compile to be possibly misconfigured for the simulator build (which can obviously lead to build failures and/or incorrect/non-existent values for architecture-dependent parameters set at configuration time).

This problem also arises without CMAKE_IOS_INSTALL_COMBINED, if you want to use Xcode to build for both device(s) and simulator(s) without re-running CMake every time you switch between the two.

Try_compile should instead call xcodebuild twice, one time with -sdk iphoneos and the other with -sdk iphonesimulator.
Steps To ReproduceConfigure a project with IOS_INSTALL_COMBINED set to TRUE, and use try_compile in this project.
TagsNo tags attached.
Attached Files? file icon TryCompileIOS.cmake [^] (6,108 bytes) 2016-04-29 05:47

 Relationships

  Notes
(0040943)
Gregor Jasny (developer)
2016-04-27 16:55

More of less the same problem arises when building fat binaries. There for example check_symbol_exists does not work reliable for symbols like __i386__ or __x86_64__.

The only way I see to handle those problems is to provide some special try_compile command where one can select SDK and ARCH.
(0040944)
Brad King (manager)
2016-04-27 17:06

There is an undocumented CMAKE_TRY_COMPILE_OSX_ARCHITECTURES variable that tells try_compile what CMAKE_OSX_ARCHITECTURES to pass to its test project. One can set this to choose the architecture to use for try_compile checks. There is currently no such option for SDK selection.

This all comes from a fundamental design limitation of CMake in that it is really only meant to target one architecture/platform at a time. Universal binary support works only because the native tools (compiler, linker, etc.) support multiple architectures in single files with single command lines. The only safe way to get per-architecture information in the case of universal binaries is to do preprocessor checks and not try_compile.
(0040945)
ranjak (reporter)
2016-04-28 04:16

I have started working on a wrapper for try_compile that issues two calls to the actual try_compile with setting CMAKE_OSX_SYSROOT to iphoneos and iphonesimulator. I don't know if it's a very clean approach, but I'll share it if I manage to get it to work.
(0040946)
ranjak (reporter)
2016-04-29 05:54

I've uploaded my wrapper. It's a try_compile "overload" that issues two try_compile calls (one for device and another for simulator) and should handle every use case. That fixes the problem for me, I hope it can for others as well.
(0041022)
Ruslan Baratov (reporter)
2016-05-04 08:02

Just for the record behaviour not related to CMAKE_IOS_INSTALL_COMBINED at all. Either *_COMBINED=TRUE or *_COMBINED=FALSE you can choose sdk by '-sdk iphoneos'/'-sdk iphonesimulator'. Actually already said: "This problem also arises without CMAKE_IOS_INSTALL_COMBINED" so I'm just clarifying this fact.
(0041036)
ranjak (reporter)
2016-05-09 08:10

You are correct, sorry for not being clearer about that.
(0041045)
Gregor Jasny (developer)
2016-05-11 03:20

Just selecting any ios SDK will break with xcode containing multiple ios sdks. Please have a look at the CMakeIOSInstallCombined.cmake/_ios_install_combined_detect_sdks.

What about CMAKE_SYSTEM_FRAMEWORK_PATH (set in Platform/Darwin.cmake). It contains paths relative to the selected SYSROOT.
(0042990)
Kitware Robot (administrator)
2016-06-10 14:29

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
2016-04-27 06:41 ranjak New Issue
2016-04-27 16:55 Gregor Jasny Note Added: 0040943
2016-04-27 17:06 Brad King Note Added: 0040944
2016-04-28 04:16 ranjak Note Added: 0040945
2016-04-29 05:47 ranjak File Added: TryCompileIOS.cmake
2016-04-29 05:54 ranjak Note Added: 0040946
2016-05-04 08:02 Ruslan Baratov Note Added: 0041022
2016-05-09 08:10 ranjak Note Added: 0041036
2016-05-11 03:20 Gregor Jasny Note Added: 0041045
2016-06-10 14:29 Kitware Robot Note Added: 0042990
2016-06-10 14:29 Kitware Robot Status new => resolved
2016-06-10 14:29 Kitware Robot Resolution open => moved
2016-06-10 14:29 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team