MantisBT - CMake
View Issue Details
0013452CMakeCMakepublic2012-08-03 00:252013-01-09 10:54
Grant Limberg 
Brad King 
normalminoralways
closedfixed 
CMake 2.8.8 
CMake 2.8.10 
0013452: Invalid path generated to .o files in an object library with Xcode Generator
When linking an executable to a library built using the new object library format for add_library(), the path to the .o files is invalid when linking the final executable.

I've attached a sample project:

CMakeLists.txt - project(CMAKE-BUG)
|
| - liba/CMakeLists.txt - project(A)
|
| - exec1/CMakeLists.txt - project(exec1)
|
| - exec2/CMakeLists.txt - project(exec2)

When Xcode goes to link the .o file from liba, the path given to the linker is:

/Users/grant/Development/CMakeBug/build/liba/exec2.build/Debug/A.build/Objects-normal/x86_64/a.o'

However, the actual path to the .o file is:

clang: error: no such file or directory: '/Users/grant/Development/CMakeBug/build/liba/CMAKE-BUG.build/Debug/A.build/Objects-normal/x86_64/a.o'

Somehow the folder that should be named CMAKE-BUG.build, after the top level project name, is being replaced with the name of the last executable project name that was loaded. In this case, exec2.build.


See attached minimal sample. Build on OS X with arguments "-G Xcode"
No tags attached.
zip CMakeBug.zip (2,586) 2012-08-03 00:25
https://public.kitware.com/Bug/file/4415/CMakeBug.zip
Issue History
2012-08-03 00:25Grant LimbergNew Issue
2012-08-03 00:25Grant LimbergFile Added: CMakeBug.zip
2012-08-03 09:41Brad KingNote Added: 0030163
2012-08-03 09:41Brad KingAssigned To => Brad King
2012-08-03 09:41Brad KingStatusnew => assigned
2012-08-03 10:31Brad KingNote Added: 0030164
2012-08-03 10:31Brad KingStatusassigned => resolved
2012-08-03 10:31Brad KingResolutionopen => fixed
2012-08-03 10:31Brad KingTarget Version => CMake 2.8.10
2013-01-09 10:54Robert MaynardNote Added: 0032009
2013-01-09 10:54Robert MaynardStatusresolved => closed

Notes
(0030163)
Brad King   
2012-08-03 09:41   
Try this patch:
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 938977b..c366bcb 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -3739,7 +3739,7 @@ cmGlobalXCodeGenerator
 
   const char* configName = this->GetCMakeCFGIntDir();
   std::string dir = this->GetObjectsNormalDirectory(
-    this->CurrentProject, configName, gt->Target);
+    "$(PROJECT_NAME)", configName, gt->Target);
   if(this->XcodeVersion >= 21)
     {
     dir += "$(CURRENT_ARCH)/";
(0030164)
Brad King   
2012-08-03 10:31   
Fixed and test added:

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

Thanks for the detailed report.
(0032009)
Robert Maynard   
2013-01-09 10:54   
Closing resolved issues that have not been updated in more than 4 months.