summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2019-06-09 19:51:00 (GMT)
committerBrad King <brad.king@kitware.com>2019-06-17 18:09:15 (GMT)
commit2746c61e6d36f3d49744b11259395a8684007e9f (patch)
treeeb7c2ed37f45ec21372ddca4d7b1593c555e182f /Source
parent77e59e442d110b2cb3c5d206e79f631175805974 (diff)
downloadCMake-2746c61e6d36f3d49744b11259395a8684007e9f.zip
CMake-2746c61e6d36f3d49744b11259395a8684007e9f.tar.gz
CMake-2746c61e6d36f3d49744b11259395a8684007e9f.tar.bz2
Swift: Add library search paths for dependencies
When building Swift executables and libraries which import a module, an implicit link will be added by the driver. Because this links by name rather than path, the library search path needs to be provided to indicate where to find the library. For all local dependencies, add the library paths for the targets when linking. This ensures that you can link against local libraries without explicitly setting a library path. Fixes: #19304
Diffstat (limited to 'Source')
-rw-r--r--Source/cmLinkLineComputer.cxx34
1 files changed, 27 insertions, 7 deletions
diff --git a/Source/cmLinkLineComputer.cxx b/Source/cmLinkLineComputer.cxx
index 2a8bee6..469faca 100644
--- a/Source/cmLinkLineComputer.cxx
+++ b/Source/cmLinkLineComputer.cxx
@@ -99,14 +99,34 @@ std::string cmLinkLineComputer::ComputeLinkPath(
std::string const& libPathTerminator)
{
std::string linkPath;
- std::vector<std::string> const& libDirs = cli.GetDirectories();
- for (std::string const& libDir : libDirs) {
- std::string libpath = this->ConvertToOutputForExisting(libDir);
- linkPath += " " + libPathFlag;
- linkPath += libpath;
- linkPath += libPathTerminator;
- linkPath += " ";
+
+ if (cli.GetLinkLanguage() == "Swift") {
+ for (const cmComputeLinkInformation::Item& item : cli.GetItems()) {
+ const cmGeneratorTarget* target = item.Target;
+ if (!target) {
+ continue;
+ }
+
+ if (target->GetType() == cmStateEnums::STATIC_LIBRARY ||
+ target->GetType() == cmStateEnums::SHARED_LIBRARY) {
+ cmStateEnums::ArtifactType type = cmStateEnums::RuntimeBinaryArtifact;
+ if (target->GetType() == cmStateEnums::SHARED_LIBRARY &&
+ target->IsDLLPlatform()) {
+ type = cmStateEnums::ImportLibraryArtifact;
+ }
+
+ linkPath += " " + libPathFlag +
+ item.Target->GetDirectory(cli.GetConfig(), type) +
+ libPathTerminator + " ";
+ }
+ }
}
+
+ for (std::string const& libDir : cli.GetDirectories()) {
+ linkPath += " " + libPathFlag + this->ConvertToOutputForExisting(libDir) +
+ libPathTerminator + " ";
+ }
+
return linkPath;
}