From b237dbd8c35c2ec7b43161612fd03e89d85756e6 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 3 Aug 2012 08:58:48 -0400 Subject: [PATCH] Xcode: Fix object library references in multi-project trees (#13452) In cmGlobalXCodeGenerator::Generate we generate a .xcodeproj for each directory in the tree containing a project() command. First we iteratively use SetGenerationRoot to add "ALL_BUILD" and other targets to each project. This leaves "CurrentProject" set to the last project when we invoke cmGlobalGenerator::Generate, which is not the same as the top-level project if any subdirectories invoke the project() command. When cmGlobalGenerator::Generate reaches CreateGeneratorTargets it constructs cmGeneratorTarget and calls ComputeTargetObjects exactly once per target. In this context the value of CurrentProject is undefined so we cannot pass it to GetObjectsNormalDirectory. Use "$(PROJECT_NAME)" instead so it will adapt automatically to each project. Also teach Tests/ObjectLibrary to cover this case. --- Source/cmGlobalXCodeGenerator.cxx | 2 +- Tests/ObjectLibrary/A/CMakeLists.txt | 1 + Tests/ObjectLibrary/B/CMakeLists.txt | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 938977bfb..c366bcb73 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)/"; diff --git a/Tests/ObjectLibrary/A/CMakeLists.txt b/Tests/ObjectLibrary/A/CMakeLists.txt index 121a8acba..04ab02f16 100644 --- a/Tests/ObjectLibrary/A/CMakeLists.txt +++ b/Tests/ObjectLibrary/A/CMakeLists.txt @@ -1,3 +1,4 @@ +project(ObjectLibraryA) # Add -fPIC so objects can be used in shared libraries. # TODO: Need property for this. if(CMAKE_SHARED_LIBRARY_C_FLAGS AND NOT WATCOM) diff --git a/Tests/ObjectLibrary/B/CMakeLists.txt b/Tests/ObjectLibrary/B/CMakeLists.txt index 67172d132..4b0b07d1c 100644 --- a/Tests/ObjectLibrary/B/CMakeLists.txt +++ b/Tests/ObjectLibrary/B/CMakeLists.txt @@ -1,3 +1,4 @@ +project(ObjectLibraryB) if("${CMAKE_GENERATOR}" MATCHES "Visual Studio 6") # VS 6 generator does not use per-target object locations. set(vs6 _vs6)