The following issue has been SUBMITTED. ====================================================================== https://public.kitware.com/Bug/view.php?id=16040 ====================================================================== Reported By: Colin Cornaby Assigned To: ====================================================================== Project: CMake Issue ID: 16040 Category: CMake Reproducibility: always Severity: major Priority: high Status: new ====================================================================== Date Submitted: 2016-03-30 16:57 EDT Last Modified: 2016-03-30 16:57 EDT ====================================================================== Summary: Generated Xcode Projects Have Wrong Paths to Object Library Dependencies Description: We have a CMake project that has object libraries, and then a parent build target that wraps those object libraries into a static library. When I generate the Xcode output, the parent build target is referencing different paths than what the .o's were outputted to.
I have a patch that fixes the issue, but I wanted to open a bug first, especially if I'm duplicating something (apologies, this is my first CMake bug.) The section of code that seems to be the issue in the Xcode generator is here: cmGlobalXCodeGenerator::GetObjectsNormalDirectory( const std::string &projName, const std::string &configName, const cmGeneratorTarget *t) const { std::string dir = t->GetLocalGenerator()->GetCurrentBinaryDirectory(); dir += "/"; dir += projName; dir += ".build/"; dir += configName; dir += "/"; dir += t->GetName(); dir += ".build/Objects-normal/"; return dir; } There are a few things wrong here: - The configuration name should be part of this path. Specifically the section of that path that is "foo.build/release" should be "foo.build/release-iphoneos". This behavior could be different for Mac targets, but I'm pretty sure it isn't. One reason I'm not straight submitting the patch yet. - The .o files get written to the temporary objects directory, not the binary output directory. I've wrapped this in a new function: std::string cmGlobalXCodeGenerator::GetTemporaryFilesDirectory( const std::string &projName, const std::string &configName, const cmGeneratorTarget *t) const { std::string dir = t->GetLocalGenerator()->GetCurrentBinaryDirectory(); dir += "/"; dir += projName; dir += ".build/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/"; return dir; } I've then altered a few functions. GetObjectsNormalDirectory becomes: //---------------------------------------------------------------------------- std::string cmGlobalXCodeGenerator::GetObjectsNormalDirectory( const std::string &projName, const std::string &configName, const cmGeneratorTarget *t) const { std::string dir = GetTemporaryFilesDirectory(projName, configName, t); dir += t->GetName(); dir += ".build/Objects-normal/"; return dir; } The build setting creation gets altered a bit a well with: if(this->XcodeVersion >= 21) { std::string pncdir = this->GetObjectsNormalDirectory( this->CurrentProject, configName, gtgt); std::string tempdir = this->GetTemporaryFilesDirectory( this->CurrentProject, configName, gtgt); buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR", this->CreateString(pncdir.c_str())); buildSettings->AddAttribute("CONFIGURATION_TEMP_DIR", this->CreateString(tempdir.c_str())); } else { buildSettings->AddAttribute("OBJROOT", this->CreateString(pndir.c_str())); pndir = this->GetObjectsNormalDirectory( this->CurrentProject, configName, gtgt); } } Again, mostly submitting this bug because I'm new to Cmake and I don't know if this is patching on top of behavior that is platform dependent. Please let me know if there is something I am missing here, or if I'm breaking something else with these patches! (I'm attaching a Git patch as well) ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2016-03-30 16:57 Colin Cornaby New Issue 2016-03-30 16:57 Colin Cornaby File Added: 0001-Fixes-for-.o-generation.patch ====================================================================== -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers