diff options
author | Craig Scott <craig.scott@crascit.com> | 2020-11-16 19:23:44 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-11-16 19:23:52 (GMT) |
commit | 67ebcfbcbb752fd3b6d6cc160ec777c174e57316 (patch) | |
tree | 8bf0df42030a6c60220405d5af8a21b287fc524a | |
parent | 01b473b81098e95ac3e6cbf173c78bf02bdf036c (diff) | |
parent | b1ef2fffe73570dfdbb244e19dd66bed2d6f10c4 (diff) | |
download | CMake-67ebcfbcbb752fd3b6d6cc160ec777c174e57316.zip CMake-67ebcfbcbb752fd3b6d6cc160ec777c174e57316.tar.gz CMake-67ebcfbcbb752fd3b6d6cc160ec777c174e57316.tar.bz2 |
Merge topic 'xcode-clean-lib-paths'
b1ef2fffe7 Xcode: Clean library paths to avoid linker duplicate symbol definitions
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5511
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 91f8c2b..026e96c 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3441,10 +3441,16 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) if (!libTarget) { if (libItem->IsPath) { // Get or create a direct file ref in the root project - auto it = this->ExternalLibRefs.find(libItem->Value.Value); + auto cleanPath = libItem->Value.Value; + if (cmSystemTools::FileIsFullPath(cleanPath)) { + // Some arguments are reported as paths, but they are actually not, + // so we can't collapse them, and neither can we collapse relative + // paths + cleanPath = cmSystemTools::CollapseFullPath(cleanPath); + } + auto it = this->ExternalLibRefs.find(cleanPath); if (it == this->ExternalLibRefs.end()) { - buildFile = CreateXCodeBuildFileFromPath(libItem->Value.Value, gt, - "", nullptr); + buildFile = CreateXCodeBuildFileFromPath(cleanPath, gt, "", nullptr); if (!buildFile) { // Add this library item back to a regular linker flag list for (const auto& conf : configItemMap) { @@ -3452,7 +3458,7 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) } continue; } - this->ExternalLibRefs.emplace(libItem->Value.Value, buildFile); + this->ExternalLibRefs.emplace(cleanPath, buildFile); } else { buildFile = it->second; } @@ -3584,7 +3590,11 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) for (auto const& libItem : configItemMap[configName]) { auto const& libName = *libItem; if (libName.IsPath) { - const auto libPath = GetLibraryOrFrameworkPath(libName.Value.Value); + auto cleanPath = libName.Value.Value; + if (cmSystemTools::FileIsFullPath(cleanPath)) { + cleanPath = cmSystemTools::CollapseFullPath(cleanPath); + } + const auto libPath = GetLibraryOrFrameworkPath(cleanPath); if (cmSystemTools::StringEndsWith(libPath.c_str(), ".framework")) { const auto fwName = cmSystemTools::GetFilenameWithoutExtension(libPath); @@ -3592,17 +3602,17 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) libPaths.Add("-F " + this->XCodeEscapePath(fwDir)); libPaths.Add("-framework " + fwName); } else { - libPaths.Add(this->XCodeEscapePath(libName.Value.Value)); + libPaths.Add(this->XCodeEscapePath(cleanPath)); } if ((!libName.Target || libName.Target->IsImported()) && IsLinkPhaseLibraryExtension(libPath)) { // Create file reference for embedding - auto it = this->ExternalLibRefs.find(libName.Value.Value); + auto it = this->ExternalLibRefs.find(cleanPath); if (it == this->ExternalLibRefs.end()) { - auto* buildFile = this->CreateXCodeBuildFileFromPath( - libName.Value.Value, gt, "", nullptr); + auto* buildFile = + this->CreateXCodeBuildFileFromPath(cleanPath, gt, "", nullptr); if (buildFile) { - this->ExternalLibRefs.emplace(libName.Value.Value, buildFile); + this->ExternalLibRefs.emplace(cleanPath, buildFile); } } } |