diff options
author | Gusts Kaksis <gusts.kaksis@sonarworks.com> | 2020-07-11 12:21:47 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-07-14 12:08:45 (GMT) |
commit | 3603ca8e86c5bc41af7f2559ecd072e2df2caf83 (patch) | |
tree | febd65e07a8ce9c85966d1cea6506687eb0e1f5c /Source/cmGlobalXCodeGenerator.cxx | |
parent | e637744c515b1e61d58bfd3539a2ab5afc78f5bb (diff) | |
download | CMake-3603ca8e86c5bc41af7f2559ecd072e2df2caf83.zip CMake-3603ca8e86c5bc41af7f2559ecd072e2df2caf83.tar.gz CMake-3603ca8e86c5bc41af7f2559ecd072e2df2caf83.tar.bz2 |
Xcode: Special treatment for directly linked framework binaries
Always refer to framework directory instead of binary directly.
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d0f2e24..2d47d2c 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1038,17 +1038,31 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath( fileType = *l; } } + // Make a copy so that we can override it later + std::string path = fullpath; // Compute the extension without leading '.'. - std::string ext = cmSystemTools::GetFilenameLastExtension(fullpath); + std::string ext = cmSystemTools::GetFilenameLastExtension(path); if (!ext.empty()) { ext = ext.substr(1); } if (fileType.empty()) { + // If file has no extension it's either a raw executable or might + // be a direct reference to binary within a framework (bad practice!) + // so this is where we change the path to the point to framework + // directory. + if (ext.empty()) { + auto parentDir = cmSystemTools::GetParentDirectory(path); + auto parentExt = cmSystemTools::GetFilenameLastExtension(parentDir); + if (parentExt == ".framework") { + path = parentDir; + ext = parentExt.substr(1); + } + } // If fullpath references a directory, then we need to specify // lastKnownFileType as folder in order for Xcode to be able to // open the contents of the folder. // (Xcode 4.6 does not like explicitFileType=folder). - if (cmSystemTools::FileIsDirectory(fullpath)) { + if (cmSystemTools::FileIsDirectory(path)) { fileType = GetDirectoryValueFromFileExtension(ext); useLastKnownFileType = true; } else { @@ -1057,11 +1071,11 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath( } } - std::string key = GetGroupMapKeyFromPath(target, fullpath); + std::string key = GetGroupMapKeyFromPath(target, path); cmXCodeObject* fileRef = this->FileRefs[key]; if (!fileRef) { fileRef = this->CreateObject(cmXCodeObject::PBXFileReference); - fileRef->SetComment(fullpath); + fileRef->SetComment(path); this->FileRefs[key] = fileRef; } fileRef->AddAttribute("fileEncoding", this->CreateString("4")); @@ -1069,9 +1083,8 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath( : "explicitFileType", this->CreateString(fileType)); // Store the file path relative to the top of the source tree. - std::string path = fullpath; if (!IsLibraryType(fileType)) { - path = this->RelativeToSource(fullpath); + path = this->RelativeToSource(path); } std::string name = cmSystemTools::GetFilenameName(path); const char* sourceTree = |