View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015835CMakeCMakepublic2015-11-05 16:442016-06-10 14:31
ReporterDavid Ryskalczyk 
Assigned ToKitware Robot 
PriorityhighSeveritymajorReproducibilityalways
StatusclosedResolutionmoved 
PlatformAppleOSMac OS XOS Version10.11
Product VersionCMake 3.3.2 
Target VersionFixed in Version 
Summary0015835: Teach BasicConfigVersion to support Apple universal binaries
DescriptionCMake currently hardcodes the bitness of a built package in the .cmake config file. As Mac OS X supports universal binaries, where a package can be compiled as both 32 and 64 bit, this is inaccurate, and causes problems when linking to libraries built as universal using CMAKE_OSX_ARCHITECTURES.
This affects all versions of Mac OS X.
Steps To ReproduceBuild a library as a universal binary (using -DCMAKE_OSX_ARCHITECTURES=x86_64;i386); then try compiling a program that uses that library as either x86_64 or i386. One of them will work, the other will not. If the Config .cmake file is opened in an editor, it is obvious that the bitness is recorded and checked, based on the value of CMAKE_SIZEOF_VOID_P — which is inaccurate when the binary is built as universal.
Additional InformationA better fix might be to store a list of architectures/bitness that the package is built as, but I'm unsure of how to do this in CMake.

A patch is attached which simply ignores the bitness section of the config .cmake files when building on OS X.
TagsNo tags attached.
Attached Filesdiff file icon cmake-osx-universal-patch.diff [^] (2,026 bytes) 2015-11-05 16:44 [Show Content]

 Relationships

  Notes
(0039841)
Brad King (manager)
2015-11-06 08:36

The purpose of the CMAKE_SIZEOF_VOID_P check is to guard against architecture mismatches, so on OS X this block should somehow check CMAKE_OSX_ARCHITECTURES instead, at least if the project was built with that set.
(0039844)
David Ryskalczyk (reporter)
2015-11-06 09:23
edited on: 2015-11-06 09:24

This would require mapping from CMAKE_OSX_ARCHITECTURES to CMAKE_SIZEOF_VOID_P:

If a project is built with CMAKE_OSX_ARCHITECTURES set to i386;x86_64 (or likewise the equivalent for iOS), then it will be built in both 32-bit and 64-bit, and both 32-bit and 64-bit void pointers are acceptable. If a project then is built as single 32-bit or 64-bit and links against a universal package, CMAKE_OSX_ARCHITECTURES may not be set at all, so there may not be anything to compare to. The only solution I can see is one that would require a hardcoded list indicating that i386 is 32-bit, x86_64 is 64-bit, etc, unless there is something in the CMake internals that can be used here — and I'm not sufficiently familiar with that.

If there's a better way to do this, I'd like to know.

(0042881)
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
2015-11-05 16:44 David Ryskalczyk New Issue
2015-11-05 16:44 David Ryskalczyk File Added: cmake-osx-universal-patch.diff
2015-11-06 08:36 Brad King Note Added: 0039841
2015-11-06 09:23 David Ryskalczyk Note Added: 0039844
2015-11-06 09:24 David Ryskalczyk Note Edited: 0039844
2015-11-06 10:33 Brad King Summary CMake hardcodes bitness in .cmake files for universal binaries => Teach BasicConfigVersion to support Apple universal binaries
2016-06-10 14:29 Kitware Robot Note Added: 0042881
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