MantisBT - CMake
View Issue Details
0013935CMakeCMakepublic2013-02-19 13:032014-09-03 10:55
Rick Ballard 
Brad King 
highmajoralways
closedfixed 
AppleOS X10.8.2
CMake 2.8.10.2 
CMake 2.8.11CMake 2.8.11 
0013935: CMake generates corrupt Xcode project files due to illegal reuse of target dependencies
CMake generates corrupt Xcode project files which will cause Xcode to crash in certain circumstances.

In an Xcode project file, every time a target depends on another target there should be a unique PBXTargetDependency object in the project file representing that dependency. Even if multiple targets depend on the same other target, they should each have their own instance of a PBXTargetDependency representing that relationship to the other target. Unfortunately, CMake reuses a PBXTargetDependency object when multiple targets depend on the same other target. This will cause Xcode to crash if the user tries to delete that target dependency in Xcode's target editor UI. It may cause other problems as well, though I haven't looked into it enough to know.

Please fix CMake so that it generates a unique PBXTargetDependency in the project file for every instance of a target dependency.
1. Install cmake from http://www.cmake.org/files/v2.8/cmake-2.8.10.2-Darwin64-universal.dmg [^]
2. Download and unzip the attached sample folder that is attached.
3. Create a folder named xcodebuild inside the sample folder
4. Open a terminal and do "cd sample/xcodebuild"
5. Run the command "cmake -G Xcode .."

At this point if you inspect the text of the generated Xcode project named "HELLO", you will see that there are PBXTargetDependency objects in this file that are referenced by multiple targets. This is a bug; each PBXTargetDependency is allowed to be owned by one and only one target.

To demonstrate a crash in Xcode that this causes:

6. Open the Xcode project named HELLO that is created inside the xcodebuild folder
7. Select the Hello target, choose "Build Phases"
8. Open "Target Dependency" build phase
9. Select "ZERO_CHECK (HELLO)" dependency
10. Click "-" to remove the selected dependency
11. Wait for Xcode to crash.
Apple has received a lot of crash reports from users hitting this crash. While it is a bug that corrupt project files cause Xcode to crash instead of displaying an error, we'd appreciate it if CMake would generate correct project files.
No tags attached.
related to 0015111closed Brad King “File reference” warnings when building a CMake project with Xcode 6 
zip sample.zip (2,215) 2013-02-19 13:03
https://public.kitware.com/Bug/file/4648/sample.zip
Issue History
2013-02-19 13:03Rick BallardNew Issue
2013-02-19 13:03Rick BallardFile Added: sample.zip
2013-02-19 15:40Brad KingNote Added: 0032344
2013-02-19 16:01Rick BallardNote Added: 0032345
2013-02-19 16:17Brad KingNote Added: 0032346
2013-02-19 16:24Rick BallardNote Added: 0032347
2013-02-19 17:08Brad KingNote Added: 0032349
2013-02-19 17:08Brad KingAssigned To => Brad King
2013-02-19 17:08Brad KingStatusnew => resolved
2013-02-19 17:08Brad KingResolutionopen => fixed
2013-02-19 17:08Brad KingFixed in Version => CMake 2.8.11
2013-02-19 17:08Brad KingTarget Version => CMake 2.8.11
2013-07-01 09:38Robert MaynardNote Added: 0033431
2013-07-01 09:38Robert MaynardStatusresolved => closed
2014-09-03 10:55Brad KingRelationship addedrelated to 0015111

Notes
(0032344)
Brad King   
2013-02-19 15:40   
Is there any documentation of Xcode's format or the object model it serializes?

CMake's generator was written by creating projects by hand in the IDE and reading the pbxproj files produced.
(0032345)
Rick Ballard   
2013-02-19 16:01   
There is no documentation of the format; we don't officially support generating Xcode project files. But if you look at the project files Xcode generates, you'll notice that Xcode never re-uses PBXTargetDependency objects for multiple targets the way CMake is doing.
(0032346)
Brad King   
2013-02-19 16:17   
Does the associated PBXContainerItemProxy need to be duplicated for each dependency graph edge too or can that be shared as it is now?
(0032347)
Rick Ballard   
2013-02-19 16:24   
Yes; each PBXTargetDependency should have a unique PBXContainerItemProxy as its targetProxy.
(0032349)
Brad King   
2013-02-19 17:08   
Thanks for tracking it down this far and providing the detailed report.

Ironically the current CMake implementation goes out of its way to avoid duplicating the PBXTargetDependency objects.

After some cleanup:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=781ea6d1 [^]

I've committed a fix:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b0051404 [^]
(0033431)
Robert Maynard   
2013-07-01 09:38   
Closing resolved issues that have not been updated in more than 4 months.