|
|
@@ -422,25 +422,6 @@ cmComputeLinkInformation::cmComputeLinkInformation(
|
|
|
this->OrderDependentRPath->AddLanguageDirectories(this->RuntimeLinkDirs);
|
|
|
}
|
|
|
|
|
|
- // Decide whether to enable compatible library search path mode.
|
|
|
- // There exists code that effectively does
|
|
|
- //
|
|
|
- // /path/to/libA.so -lB
|
|
|
- //
|
|
|
- // where -lB is meant to link to /path/to/libB.so. This is broken
|
|
|
- // because it specified -lB without specifying a link directory (-L)
|
|
|
- // in which to search for B. This worked in CMake 2.4 and below
|
|
|
- // because -L/path/to would be added by the -L/-l split for A. In
|
|
|
- // order to support such projects we need to add the directories
|
|
|
- // containing libraries linked with a full path to the -L path.
|
|
|
- this->OldLinkDirMode =
|
|
|
- this->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW;
|
|
|
- if (this->OldLinkDirMode) {
|
|
|
- // Construct a mask to not bother with this behavior for link
|
|
|
- // directories already specified by the user.
|
|
|
- this->OldLinkDirMask.insert(directories.begin(), directories.end());
|
|
|
- }
|
|
|
-
|
|
|
this->CMP0060Warn = this->Makefile->PolicyOptionalWarningEnabled(
|
|
|
"CMAKE_POLICY_WARNING_CMP0060");
|
|
|
}
|
|
|
@@ -587,7 +568,6 @@ bool cmComputeLinkInformation::Compute()
|
|
|
// Compute the ordered link line items.
|
|
|
cmComputeLinkDepends cld(this->Target, this->Config, this->LinkLanguage,
|
|
|
strategy);
|
|
|
- cld.SetOldLinkDirMode(this->OldLinkDirMode);
|
|
|
cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute();
|
|
|
FeatureDescriptor const* currentFeature = nullptr;
|
|
|
|
|
|
@@ -667,27 +647,6 @@ bool cmComputeLinkInformation::Compute()
|
|
|
this->SetCurrentLinkType(this->StartLinkType);
|
|
|
}
|
|
|
|
|
|
- // Finish listing compatibility paths.
|
|
|
- if (this->OldLinkDirMode) {
|
|
|
- // For CMake 2.4 bug-compatibility we need to consider the output
|
|
|
- // directories of targets linked in another configuration as link
|
|
|
- // directories.
|
|
|
- std::set<cmGeneratorTarget const*> const& wrongItems =
|
|
|
- cld.GetOldWrongConfigItems();
|
|
|
- for (cmGeneratorTarget const* tgt : wrongItems) {
|
|
|
- cmStateEnums::ArtifactType artifact = tgt->HasImportLibrary(this->Config)
|
|
|
- ? cmStateEnums::ImportLibraryArtifact
|
|
|
- : cmStateEnums::RuntimeBinaryArtifact;
|
|
|
- this->OldLinkDirItems.push_back(
|
|
|
- tgt->GetFullPath(this->Config, artifact, true));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // Finish setting up linker search directories.
|
|
|
- if (!this->FinishLinkerSearchDirectories()) {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
// Add implicit language runtime libraries and directories.
|
|
|
this->AddImplicitLinkInfo();
|
|
|
|
|
|
@@ -1301,7 +1260,7 @@ void cmComputeLinkInformation::AddItem(LinkEntry const& entry)
|
|
|
}
|
|
|
} else if (entry.Kind != cmComputeLinkDepends::LinkEntry::Object) {
|
|
|
// This is a library or option specified by the user.
|
|
|
- this->AddUserItem(entry, true);
|
|
|
+ this->AddUserItem(entry);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1674,14 +1633,6 @@ void cmComputeLinkInformation::AddTargetItem(LinkEntry const& entry)
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // For compatibility with CMake 2.4 include the item's directory in
|
|
|
- // the linker search path.
|
|
|
- if (this->OldLinkDirMode && !target->IsFrameworkOnApple() &&
|
|
|
- !cm::contains(this->OldLinkDirMask,
|
|
|
- cmSystemTools::GetFilenamePath(item.Value))) {
|
|
|
- this->OldLinkDirItems.push_back(item.Value);
|
|
|
- }
|
|
|
-
|
|
|
const bool isImportedFrameworkFolderOnApple =
|
|
|
target->IsImportedFrameworkFolderOnApple(this->Config);
|
|
|
if (target->IsFrameworkOnApple() || isImportedFrameworkFolderOnApple) {
|
|
|
@@ -1790,14 +1741,6 @@ void cmComputeLinkInformation::AddFullItem(LinkEntry const& entry)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // For compatibility with CMake 2.4 include the item's directory in
|
|
|
- // the linker search path.
|
|
|
- if (this->OldLinkDirMode &&
|
|
|
- !cm::contains(this->OldLinkDirMask,
|
|
|
- cmSystemTools::GetFilenamePath(item.Value))) {
|
|
|
- this->OldLinkDirItems.push_back(item.Value);
|
|
|
- }
|
|
|
-
|
|
|
// Now add the full path to the library.
|
|
|
this->Items.emplace_back(
|
|
|
item, ItemIsPath::Yes, nullptr, entry.ObjectSource,
|
|
|
@@ -1862,7 +1805,7 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(LinkEntry const& entry)
|
|
|
// library for the architecture at link time.
|
|
|
LinkEntry fileEntry{ entry };
|
|
|
fileEntry.Item = file;
|
|
|
- this->AddUserItem(fileEntry, false);
|
|
|
+ this->AddUserItem(fileEntry);
|
|
|
|
|
|
// Make sure the link directory ordering will find the library.
|
|
|
this->OrderLinkerSearchPath->AddLinkLibrary(item.Value);
|
|
|
@@ -1870,8 +1813,7 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(LinkEntry const& entry)
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-void cmComputeLinkInformation::AddUserItem(LinkEntry const& entry,
|
|
|
- bool pathNotKnown)
|
|
|
+void cmComputeLinkInformation::AddUserItem(LinkEntry const& entry)
|
|
|
{
|
|
|
// This is called to handle a link item that does not match a CMake
|
|
|
// target and is not a full path. We check here if it looks like a
|
|
|
@@ -1886,15 +1828,6 @@ void cmComputeLinkInformation::AddUserItem(LinkEntry const& entry,
|
|
|
|
|
|
if (item.Value[0] == '-' || item.Value[0] == '$' || item.Value[0] == '`') {
|
|
|
// Pass flags through untouched.
|
|
|
- // if this is a -l option then we might need to warn about
|
|
|
- // CMP0003 so put it in OldUserFlagItems, if it is not a -l
|
|
|
- // or -Wl,-l (-framework -pthread), then allow it without a
|
|
|
- // CMP0003 as -L will not affect those other linker flags
|
|
|
- if (cmHasLiteralPrefix(item.Value, "-l") ||
|
|
|
- cmHasLiteralPrefix(item.Value, "-Wl,-l")) {
|
|
|
- // This is a linker option provided by the user.
|
|
|
- this->OldUserFlagItems.push_back(item.Value);
|
|
|
- }
|
|
|
|
|
|
// Restore the target link type since this item does not specify
|
|
|
// one.
|
|
|
@@ -1964,11 +1897,6 @@ void cmComputeLinkInformation::AddUserItem(LinkEntry const& entry,
|
|
|
// Use just the library name so the linker will search.
|
|
|
lib = this->ExtractAnyLibraryName.match(2);
|
|
|
} else {
|
|
|
- // This is a name specified by the user.
|
|
|
- if (pathNotKnown) {
|
|
|
- this->OldUserFlagItems.push_back(item.Value);
|
|
|
- }
|
|
|
-
|
|
|
// We must ask the linker to search for a library with this name.
|
|
|
// Restore the target link type since this item does not specify
|
|
|
// one.
|
|
|
@@ -2154,7 +2082,7 @@ void cmComputeLinkInformation::AddSharedLibNoSOName(LinkEntry const& entry)
|
|
|
// path instead of just the name.
|
|
|
LinkEntry fileEntry{ entry };
|
|
|
fileEntry.Item = cmSystemTools::GetFilenameName(entry.Item.Value);
|
|
|
- this->AddUserItem(fileEntry, false);
|
|
|
+ this->AddUserItem(fileEntry);
|
|
|
|
|
|
// Make sure the link directory ordering will find the library.
|
|
|
this->OrderLinkerSearchPath->AddLinkLibrary(entry.Item.Value);
|
|
|
@@ -2171,11 +2099,10 @@ void cmComputeLinkInformation::HandleBadFullItem(LinkEntry const& entry,
|
|
|
}
|
|
|
|
|
|
// Tell the linker to search for the item and provide the proper
|
|
|
- // path for it. Do not contribute to any CMP0003 warning (do not
|
|
|
- // put in OldLinkDirItems or OldUserFlagItems).
|
|
|
+ // path for it.
|
|
|
LinkEntry fileEntry{ entry };
|
|
|
fileEntry.Item = file;
|
|
|
- this->AddUserItem(fileEntry, false);
|
|
|
+ this->AddUserItem(fileEntry);
|
|
|
this->OrderLinkerSearchPath->AddLinkLibrary(item);
|
|
|
|
|
|
// Produce any needed message.
|
|
|
@@ -2206,103 +2133,6 @@ void cmComputeLinkInformation::HandleBadFullItem(LinkEntry const& entry,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-bool cmComputeLinkInformation::FinishLinkerSearchDirectories()
|
|
|
-{
|
|
|
- // Support broken projects if necessary.
|
|
|
- if (this->OldLinkDirItems.empty() || this->OldUserFlagItems.empty() ||
|
|
|
- !this->OldLinkDirMode) {
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- // Enforce policy constraints.
|
|
|
- switch (this->Target->GetPolicyStatusCMP0003()) {
|
|
|
- case cmPolicies::WARN:
|
|
|
- if (!this->CMakeInstance->GetState()->GetGlobalPropertyAsBool(
|
|
|
- "CMP0003-WARNING-GIVEN")) {
|
|
|
- this->CMakeInstance->GetState()->SetGlobalProperty(
|
|
|
- "CMP0003-WARNING-GIVEN", "1");
|
|
|
- std::ostringstream w;
|
|
|
- this->PrintLinkPolicyDiagnosis(w);
|
|
|
- this->CMakeInstance->IssueMessage(MessageType::AUTHOR_WARNING, w.str(),
|
|
|
- this->Target->GetBacktrace());
|
|
|
- }
|
|
|
- CM_FALLTHROUGH;
|
|
|
- case cmPolicies::OLD:
|
|
|
- // OLD behavior is to add the paths containing libraries with
|
|
|
- // known full paths as link directories.
|
|
|
- break;
|
|
|
- case cmPolicies::NEW:
|
|
|
- // Should never happen due to assignment of OldLinkDirMode
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- // Add the link directories for full path items.
|
|
|
- for (std::string const& i : this->OldLinkDirItems) {
|
|
|
- this->OrderLinkerSearchPath->AddLinkLibrary(i);
|
|
|
- }
|
|
|
- return true;
|
|
|
-}
|
|
|
-
|
|
|
-void cmComputeLinkInformation::PrintLinkPolicyDiagnosis(std::ostream& os)
|
|
|
-{
|
|
|
- // Tell the user what to do.
|
|
|
- /* clang-format off */
|
|
|
- os << "Policy CMP0003 should be set before this line. "
|
|
|
- "Add code such as\n"
|
|
|
- " if(COMMAND cmake_policy)\n"
|
|
|
- " cmake_policy(SET CMP0003 NEW)\n"
|
|
|
- " endif(COMMAND cmake_policy)\n"
|
|
|
- "as early as possible but after the most recent call to "
|
|
|
- "cmake_minimum_required or cmake_policy(VERSION). ";
|
|
|
- /* clang-format on */
|
|
|
-
|
|
|
- // List the items that might need the old-style paths.
|
|
|
- os << "This warning appears because target \"" << this->Target->GetName()
|
|
|
- << "\" links to some libraries for which the linker must search:\n";
|
|
|
- {
|
|
|
- // Format the list of unknown items to be as short as possible while
|
|
|
- // still fitting in the allowed width (a true solution would be the
|
|
|
- // bin packing problem if we were allowed to change the order).
|
|
|
- std::string::size_type max_size = 76;
|
|
|
- std::string line;
|
|
|
- const char* sep = " ";
|
|
|
- for (std::string const& i : this->OldUserFlagItems) {
|
|
|
- // If the addition of another item will exceed the limit then
|
|
|
- // output the current line and reset it. Note that the separator
|
|
|
- // is either " " or ", " which is always 2 characters.
|
|
|
- if (!line.empty() && (line.size() + i.size() + 2) > max_size) {
|
|
|
- os << line << '\n';
|
|
|
- sep = " ";
|
|
|
- line.clear();
|
|
|
- }
|
|
|
- line += sep;
|
|
|
- line += i;
|
|
|
- // Convert to the other separator.
|
|
|
- sep = ", ";
|
|
|
- }
|
|
|
- if (!line.empty()) {
|
|
|
- os << line << '\n';
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // List the paths old behavior is adding.
|
|
|
- os << "and other libraries with known full path:\n";
|
|
|
- std::set<std::string> emitted;
|
|
|
- for (std::string const& i : this->OldLinkDirItems) {
|
|
|
- if (emitted.insert(cmSystemTools::GetFilenamePath(i)).second) {
|
|
|
- os << " " << i << '\n';
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // Explain.
|
|
|
- os << "CMake is adding directories in the second list to the linker "
|
|
|
- "search path in case they are needed to find libraries from the "
|
|
|
- "first list (for backwards compatibility with CMake 2.4). "
|
|
|
- "Set policy CMP0003 to OLD or NEW to enable or disable this "
|
|
|
- "behavior explicitly. "
|
|
|
- "Run \"cmake --help-policy CMP0003\" for more information.";
|
|
|
-}
|
|
|
-
|
|
|
void cmComputeLinkInformation::LoadImplicitLinkInfo()
|
|
|
{
|
|
|
// Get platform-wide implicit directories.
|