cmComputeLinkInformation: Port to cmGeneratorTarget.
This commit is contained in:
parent
ee26add4f4
commit
c93230ac38
@ -242,11 +242,12 @@ because this need be done only for shared libraries without soname-s.
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmComputeLinkInformation
|
cmComputeLinkInformation
|
||||||
::cmComputeLinkInformation(cmTarget const* target, const std::string& config)
|
::cmComputeLinkInformation(const cmGeneratorTarget* target,
|
||||||
|
const std::string& config)
|
||||||
{
|
{
|
||||||
// Store context information.
|
// Store context information.
|
||||||
this->Target = target;
|
this->Target = target;
|
||||||
this->Makefile = this->Target->GetMakefile();
|
this->Makefile = this->Target->Target->GetMakefile();
|
||||||
this->GlobalGenerator = this->Makefile->GetGlobalGenerator();
|
this->GlobalGenerator = this->Makefile->GetGlobalGenerator();
|
||||||
this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance();
|
this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance();
|
||||||
|
|
||||||
@ -259,17 +260,15 @@ cmComputeLinkInformation
|
|||||||
|
|
||||||
// Allocate internals.
|
// Allocate internals.
|
||||||
this->OrderLinkerSearchPath =
|
this->OrderLinkerSearchPath =
|
||||||
new cmOrderDirectories(this->GlobalGenerator, target,
|
new cmOrderDirectories(this->GlobalGenerator, target->Target,
|
||||||
"linker search path");
|
"linker search path");
|
||||||
this->OrderRuntimeSearchPath =
|
this->OrderRuntimeSearchPath =
|
||||||
new cmOrderDirectories(this->GlobalGenerator, target,
|
new cmOrderDirectories(this->GlobalGenerator, target->Target,
|
||||||
"runtime search path");
|
"runtime search path");
|
||||||
this->OrderDependentRPath = 0;
|
this->OrderDependentRPath = 0;
|
||||||
|
|
||||||
cmGeneratorTarget *gtgt = this->GlobalGenerator
|
|
||||||
->GetGeneratorTarget(this->Target);
|
|
||||||
// Get the language used for linking this target.
|
// Get the language used for linking this target.
|
||||||
this->LinkLanguage = gtgt->GetLinkerLanguage(config);
|
this->LinkLanguage = this->Target->GetLinkerLanguage(config);
|
||||||
if(this->LinkLanguage.empty())
|
if(this->LinkLanguage.empty())
|
||||||
{
|
{
|
||||||
// The Compute method will do nothing, so skip the rest of the
|
// The Compute method will do nothing, so skip the rest of the
|
||||||
@ -283,14 +282,14 @@ cmComputeLinkInformation
|
|||||||
|
|
||||||
// Check whether we should skip dependencies on shared library files.
|
// Check whether we should skip dependencies on shared library files.
|
||||||
this->LinkDependsNoShared =
|
this->LinkDependsNoShared =
|
||||||
this->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED");
|
this->Target->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED");
|
||||||
|
|
||||||
// On platforms without import libraries there may be a special flag
|
// On platforms without import libraries there may be a special flag
|
||||||
// to use when creating a plugin (module) that obtains symbols from
|
// to use when creating a plugin (module) that obtains symbols from
|
||||||
// the program that will load it.
|
// the program that will load it.
|
||||||
this->LoaderFlag = 0;
|
this->LoaderFlag = 0;
|
||||||
if(!this->UseImportLibrary &&
|
if(!this->UseImportLibrary &&
|
||||||
this->Target->GetType() == cmTarget::MODULE_LIBRARY)
|
this->Target->Target->GetType() == cmTarget::MODULE_LIBRARY)
|
||||||
{
|
{
|
||||||
std::string loader_flag_var = "CMAKE_SHARED_MODULE_LOADER_";
|
std::string loader_flag_var = "CMAKE_SHARED_MODULE_LOADER_";
|
||||||
loader_flag_var += this->LinkLanguage;
|
loader_flag_var += this->LinkLanguage;
|
||||||
@ -308,10 +307,10 @@ cmComputeLinkInformation
|
|||||||
|
|
||||||
// Get options needed to specify RPATHs.
|
// Get options needed to specify RPATHs.
|
||||||
this->RuntimeUseChrpath = false;
|
this->RuntimeUseChrpath = false;
|
||||||
if(this->Target->GetType() != cmTarget::STATIC_LIBRARY)
|
if(this->Target->Target->GetType() != cmTarget::STATIC_LIBRARY)
|
||||||
{
|
{
|
||||||
const char* tType =
|
const char* tType =
|
||||||
((this->Target->GetType() == cmTarget::EXECUTABLE)?
|
((this->Target->Target->GetType() == cmTarget::EXECUTABLE)?
|
||||||
"EXECUTABLE" : "SHARED_LIBRARY");
|
"EXECUTABLE" : "SHARED_LIBRARY");
|
||||||
std::string rtVar = "CMAKE_";
|
std::string rtVar = "CMAKE_";
|
||||||
rtVar += tType;
|
rtVar += tType;
|
||||||
@ -325,7 +324,7 @@ cmComputeLinkInformation
|
|||||||
(this->Makefile->
|
(this->Makefile->
|
||||||
GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH"));
|
GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH"));
|
||||||
|
|
||||||
this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config);
|
this->RuntimeUseChrpath = this->Target->IsChrpathUsed(config);
|
||||||
|
|
||||||
// Get options needed to help find dependent libraries.
|
// Get options needed to help find dependent libraries.
|
||||||
std::string rlVar = "CMAKE_";
|
std::string rlVar = "CMAKE_";
|
||||||
@ -371,15 +370,15 @@ cmComputeLinkInformation
|
|||||||
{
|
{
|
||||||
this->SharedDependencyMode = SharedDepModeDir;
|
this->SharedDependencyMode = SharedDepModeDir;
|
||||||
this->OrderDependentRPath =
|
this->OrderDependentRPath =
|
||||||
new cmOrderDirectories(this->GlobalGenerator, target,
|
new cmOrderDirectories(this->GlobalGenerator, target->Target,
|
||||||
"dependent library path");
|
"dependent library path");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the search path entries requested by the user to path ordering.
|
// Add the search path entries requested by the user to path ordering.
|
||||||
this->OrderLinkerSearchPath
|
this->OrderLinkerSearchPath
|
||||||
->AddUserDirectories(this->Target->GetLinkDirectories());
|
->AddUserDirectories(this->Target->Target->GetLinkDirectories());
|
||||||
this->OrderRuntimeSearchPath
|
this->OrderRuntimeSearchPath
|
||||||
->AddUserDirectories(this->Target->GetLinkDirectories());
|
->AddUserDirectories(this->Target->Target->GetLinkDirectories());
|
||||||
|
|
||||||
// Set up the implicit link directories.
|
// Set up the implicit link directories.
|
||||||
this->LoadImplicitLinkInfo();
|
this->LoadImplicitLinkInfo();
|
||||||
@ -407,12 +406,13 @@ cmComputeLinkInformation
|
|||||||
// order to support such projects we need to add the directories
|
// order to support such projects we need to add the directories
|
||||||
// containing libraries linked with a full path to the -L path.
|
// containing libraries linked with a full path to the -L path.
|
||||||
this->OldLinkDirMode =
|
this->OldLinkDirMode =
|
||||||
this->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW;
|
this->Target->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW;
|
||||||
if(this->OldLinkDirMode)
|
if(this->OldLinkDirMode)
|
||||||
{
|
{
|
||||||
// Construct a mask to not bother with this behavior for link
|
// Construct a mask to not bother with this behavior for link
|
||||||
// directories already specified by the user.
|
// directories already specified by the user.
|
||||||
std::vector<std::string> const& dirs = this->Target->GetLinkDirectories();
|
std::vector<std::string> const& dirs =
|
||||||
|
this->Target->Target->GetLinkDirectories();
|
||||||
this->OldLinkDirMask.insert(dirs.begin(), dirs.end());
|
this->OldLinkDirMask.insert(dirs.begin(), dirs.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -497,7 +497,7 @@ bool cmComputeLinkInformation::Compute()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Compute the ordered link line items.
|
// Compute the ordered link line items.
|
||||||
cmComputeLinkDepends cld(this->Target, this->Config);
|
cmComputeLinkDepends cld(this->Target->Target, this->Config);
|
||||||
cld.SetOldLinkDirMode(this->OldLinkDirMode);
|
cld.SetOldLinkDirMode(this->OldLinkDirMode);
|
||||||
cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute();
|
cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute();
|
||||||
|
|
||||||
@ -518,7 +518,8 @@ bool cmComputeLinkInformation::Compute()
|
|||||||
|
|
||||||
// Restore the target link type so the correct system runtime
|
// Restore the target link type so the correct system runtime
|
||||||
// libraries are found.
|
// libraries are found.
|
||||||
const char* lss = this->Target->GetProperty("LINK_SEARCH_END_STATIC");
|
const char* lss =
|
||||||
|
this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC");
|
||||||
if(cmSystemTools::IsOn(lss))
|
if(cmSystemTools::IsOn(lss))
|
||||||
{
|
{
|
||||||
this->SetCurrentLinkType(LinkStatic);
|
this->SetCurrentLinkType(LinkStatic);
|
||||||
@ -571,7 +572,7 @@ bool cmComputeLinkInformation::Compute()
|
|||||||
"name."
|
"name."
|
||||||
;
|
;
|
||||||
this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
|
this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
|
||||||
this->Target->GetBacktrace());
|
this->Target->Target->GetBacktrace());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -580,12 +581,9 @@ bool cmComputeLinkInformation::Compute()
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmComputeLinkInformation::AddImplicitLinkInfo()
|
void cmComputeLinkInformation::AddImplicitLinkInfo()
|
||||||
{
|
{
|
||||||
cmGeneratorTarget *gtgt = this->Target->GetMakefile()
|
|
||||||
->GetGlobalGenerator()
|
|
||||||
->GetGeneratorTarget(this->Target);
|
|
||||||
|
|
||||||
// The link closure lists all languages whose implicit info is needed.
|
// The link closure lists all languages whose implicit info is needed.
|
||||||
cmGeneratorTarget::LinkClosure const* lc=gtgt->GetLinkClosure(this->Config);
|
cmGeneratorTarget::LinkClosure const* lc =
|
||||||
|
this->Target->GetLinkClosure(this->Config);
|
||||||
for(std::vector<std::string>::const_iterator li = lc->Languages.begin();
|
for(std::vector<std::string>::const_iterator li = lc->Languages.begin();
|
||||||
li != lc->Languages.end(); ++li)
|
li != lc->Languages.end(); ++li)
|
||||||
{
|
{
|
||||||
@ -863,7 +861,8 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lookup the starting link type from the target (linked statically?).
|
// Lookup the starting link type from the target (linked statically?).
|
||||||
const char* lss = this->Target->GetProperty("LINK_SEARCH_START_STATIC");
|
const char* lss =
|
||||||
|
this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC");
|
||||||
this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared;
|
this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared;
|
||||||
this->CurrentLinkType = this->StartLinkType;
|
this->CurrentLinkType = this->StartLinkType;
|
||||||
}
|
}
|
||||||
@ -1149,7 +1148,7 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item)
|
|||||||
// Full path libraries should specify a valid library file name.
|
// Full path libraries should specify a valid library file name.
|
||||||
// See documentation of CMP0008.
|
// See documentation of CMP0008.
|
||||||
std::string generator = this->GlobalGenerator->GetName();
|
std::string generator = this->GlobalGenerator->GetName();
|
||||||
if(this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW &&
|
if(this->Target->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW &&
|
||||||
(generator.find("Visual Studio") != generator.npos ||
|
(generator.find("Visual Studio") != generator.npos ||
|
||||||
generator.find("Xcode") != generator.npos))
|
generator.find("Xcode") != generator.npos))
|
||||||
{
|
{
|
||||||
@ -1230,7 +1229,7 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check the policy for whether we should use the approach below.
|
// Check the policy for whether we should use the approach below.
|
||||||
switch (this->Target->GetPolicyStatusCMP0060())
|
switch (this->Target->Target->GetPolicyStatusCMP0060())
|
||||||
{
|
{
|
||||||
case cmPolicies::WARN:
|
case cmPolicies::WARN:
|
||||||
if (this->CMP0060Warn)
|
if (this->CMP0060Warn)
|
||||||
@ -1540,7 +1539,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
|
|||||||
this->OrderLinkerSearchPath->AddLinkLibrary(item);
|
this->OrderLinkerSearchPath->AddLinkLibrary(item);
|
||||||
|
|
||||||
// Produce any needed message.
|
// Produce any needed message.
|
||||||
switch(this->Target->GetPolicyStatusCMP0008())
|
switch(this->Target->Target->GetPolicyStatusCMP0008())
|
||||||
{
|
{
|
||||||
case cmPolicies::WARN:
|
case cmPolicies::WARN:
|
||||||
{
|
{
|
||||||
@ -1557,7 +1556,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
|
|||||||
<< " " << item << "\n"
|
<< " " << item << "\n"
|
||||||
<< "which is a full-path but not a valid library file name.";
|
<< "which is a full-path but not a valid library file name.";
|
||||||
this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
|
this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
|
||||||
this->Target->GetBacktrace());
|
this->Target->Target->GetBacktrace());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case cmPolicies::OLD:
|
case cmPolicies::OLD:
|
||||||
@ -1575,7 +1574,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
|
|||||||
<< " " << item << "\n"
|
<< " " << item << "\n"
|
||||||
<< "which is a full-path but not a valid library file name.";
|
<< "which is a full-path but not a valid library file name.";
|
||||||
this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(),
|
this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(),
|
||||||
this->Target->GetBacktrace());
|
this->Target->Target->GetBacktrace());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1592,7 +1591,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Enforce policy constraints.
|
// Enforce policy constraints.
|
||||||
switch(this->Target->GetPolicyStatusCMP0003())
|
switch(this->Target->Target->GetPolicyStatusCMP0003())
|
||||||
{
|
{
|
||||||
case cmPolicies::WARN:
|
case cmPolicies::WARN:
|
||||||
if(!this->CMakeInstance->GetState()
|
if(!this->CMakeInstance->GetState()
|
||||||
@ -1603,7 +1602,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories()
|
|||||||
std::ostringstream w;
|
std::ostringstream w;
|
||||||
this->PrintLinkPolicyDiagnosis(w);
|
this->PrintLinkPolicyDiagnosis(w);
|
||||||
this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
|
this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
|
||||||
this->Target->GetBacktrace());
|
this->Target->Target->GetBacktrace());
|
||||||
}
|
}
|
||||||
case cmPolicies::OLD:
|
case cmPolicies::OLD:
|
||||||
// OLD behavior is to add the paths containing libraries with
|
// OLD behavior is to add the paths containing libraries with
|
||||||
@ -1619,7 +1618,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories()
|
|||||||
e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0003) << "\n";
|
e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0003) << "\n";
|
||||||
this->PrintLinkPolicyDiagnosis(e);
|
this->PrintLinkPolicyDiagnosis(e);
|
||||||
this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(),
|
this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(),
|
||||||
this->Target->GetBacktrace());
|
this->Target->Target->GetBacktrace());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1923,23 +1922,24 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
|
|||||||
// build tree.
|
// build tree.
|
||||||
bool linking_for_install =
|
bool linking_for_install =
|
||||||
(for_install ||
|
(for_install ||
|
||||||
this->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH"));
|
this->Target->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH"));
|
||||||
bool use_install_rpath =
|
bool use_install_rpath =
|
||||||
(outputRuntime && this->Target->HaveInstallTreeRPATH() &&
|
(outputRuntime && this->Target->Target->HaveInstallTreeRPATH() &&
|
||||||
linking_for_install);
|
linking_for_install);
|
||||||
bool use_build_rpath =
|
bool use_build_rpath =
|
||||||
(outputRuntime && this->Target->HaveBuildTreeRPATH(this->Config) &&
|
(outputRuntime && this->Target->Target->HaveBuildTreeRPATH(this->Config) &&
|
||||||
!linking_for_install);
|
!linking_for_install);
|
||||||
bool use_link_rpath =
|
bool use_link_rpath =
|
||||||
outputRuntime && linking_for_install &&
|
outputRuntime && linking_for_install &&
|
||||||
!this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH") &&
|
!this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH") &&
|
||||||
this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH");
|
this->Target->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH");
|
||||||
|
|
||||||
// Construct the RPATH.
|
// Construct the RPATH.
|
||||||
std::set<std::string> emitted;
|
std::set<std::string> emitted;
|
||||||
if(use_install_rpath)
|
if(use_install_rpath)
|
||||||
{
|
{
|
||||||
const char* install_rpath = this->Target->GetProperty("INSTALL_RPATH");
|
const char* install_rpath =
|
||||||
|
this->Target->Target->GetProperty("INSTALL_RPATH");
|
||||||
cmCLI_ExpandListUnique(install_rpath, runtimeDirs, emitted);
|
cmCLI_ExpandListUnique(install_rpath, runtimeDirs, emitted);
|
||||||
}
|
}
|
||||||
if(use_build_rpath || use_link_rpath)
|
if(use_build_rpath || use_link_rpath)
|
||||||
@ -2011,12 +2011,8 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
|
|||||||
// Add runtime paths required by the languages to always be
|
// Add runtime paths required by the languages to always be
|
||||||
// present. This is done even when skipping rpath support.
|
// present. This is done even when skipping rpath support.
|
||||||
{
|
{
|
||||||
cmGeneratorTarget *gtgt = this->Makefile
|
|
||||||
->GetGlobalGenerator()
|
|
||||||
->GetGeneratorTarget(this->Target);
|
|
||||||
|
|
||||||
cmGeneratorTarget::LinkClosure const* lc =
|
cmGeneratorTarget::LinkClosure const* lc =
|
||||||
gtgt->GetLinkClosure(this->Config);
|
this->Target->GetLinkClosure(this->Config);
|
||||||
for(std::vector<std::string>::const_iterator li = lc->Languages.begin();
|
for(std::vector<std::string>::const_iterator li = lc->Languages.begin();
|
||||||
li != lc->Languages.end(); ++li)
|
li != lc->Languages.end(); ++li)
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,8 @@ class cmOrderDirectories;
|
|||||||
class cmComputeLinkInformation
|
class cmComputeLinkInformation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cmComputeLinkInformation(cmTarget const* target, const std::string& config);
|
cmComputeLinkInformation(cmGeneratorTarget const* target,
|
||||||
|
const std::string& config);
|
||||||
~cmComputeLinkInformation();
|
~cmComputeLinkInformation();
|
||||||
bool Compute();
|
bool Compute();
|
||||||
|
|
||||||
@ -73,7 +74,7 @@ private:
|
|||||||
std::set<cmTarget const*> SharedLibrariesLinked;
|
std::set<cmTarget const*> SharedLibrariesLinked;
|
||||||
|
|
||||||
// Context information.
|
// Context information.
|
||||||
cmTarget const* Target;
|
cmGeneratorTarget const* Target;
|
||||||
cmMakefile* Makefile;
|
cmMakefile* Makefile;
|
||||||
cmGlobalGenerator* GlobalGenerator;
|
cmGlobalGenerator* GlobalGenerator;
|
||||||
cmake* CMakeInstance;
|
cmake* CMakeInstance;
|
||||||
|
@ -3166,7 +3166,7 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const
|
|||||||
{
|
{
|
||||||
// Compute information for this configuration.
|
// Compute information for this configuration.
|
||||||
cmComputeLinkInformation* info =
|
cmComputeLinkInformation* info =
|
||||||
new cmComputeLinkInformation(this->Target, config);
|
new cmComputeLinkInformation(this, config);
|
||||||
if(!info || !info->Compute())
|
if(!info || !info->Compute())
|
||||||
{
|
{
|
||||||
delete info;
|
delete info;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user