cmGeneratorTarget: Move GetLinkerLanguage from cmTarget.
This commit is contained in:
parent
6da99de323
commit
7c809fa2a6
|
@ -265,8 +265,10 @@ cmComputeLinkInformation
|
|||
"runtime search path");
|
||||
this->OrderDependentRPath = 0;
|
||||
|
||||
cmGeneratorTarget *gtgt = this->GlobalGenerator
|
||||
->GetGeneratorTarget(this->Target);
|
||||
// Get the language used for linking this target.
|
||||
this->LinkLanguage = this->Target->GetLinkerLanguage(config);
|
||||
this->LinkLanguage = gtgt->GetLinkerLanguage(config);
|
||||
if(this->LinkLanguage.empty())
|
||||
{
|
||||
// The Compute method will do nothing, so skip the rest of the
|
||||
|
@ -322,9 +324,6 @@ cmComputeLinkInformation
|
|||
(this->Makefile->
|
||||
GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH"));
|
||||
|
||||
cmGeneratorTarget *gtgt = this->Target->GetMakefile()
|
||||
->GetGlobalGenerator()
|
||||
->GetGeneratorTarget(this->Target);
|
||||
this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config);
|
||||
|
||||
// Get options needed to help find dependent libraries.
|
||||
|
|
|
@ -990,6 +990,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
|
|||
|
||||
assert(target);
|
||||
|
||||
cmGeneratorTarget* gtgt =
|
||||
context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target);
|
||||
|
||||
if (propertyName == "LINKER_LANGUAGE")
|
||||
{
|
||||
if (target->LinkLanguagePropagatesToDependents() &&
|
||||
|
@ -1001,7 +1004,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
|
|||
"link libraries for a static library");
|
||||
return std::string();
|
||||
}
|
||||
return target->GetLinkerLanguage(context->Config);
|
||||
return gtgt->GetLinkerLanguage(context->Config);
|
||||
}
|
||||
|
||||
cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace,
|
||||
|
@ -1128,9 +1131,6 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
|
|||
}
|
||||
}
|
||||
|
||||
cmGeneratorTarget* gtgt =
|
||||
context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target);
|
||||
|
||||
if (!prop)
|
||||
{
|
||||
if (target->IsImported()
|
||||
|
@ -1600,7 +1600,7 @@ struct TargetFilesystemArtifactResultCreator<ArtifactPdbTag>
|
|||
cmGeneratorExpressionContext *context,
|
||||
const GeneratorExpressionContent *content)
|
||||
{
|
||||
std::string language = target->Target->GetLinkerLanguage(context->Config);
|
||||
std::string language = target->GetLinkerLanguage(context->Config);
|
||||
|
||||
std::string pdbSupportVar = "CMAKE_" + language + "_LINKER_SUPPORTS_PDB";
|
||||
|
||||
|
|
|
@ -709,8 +709,7 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const
|
|||
return ((this->GetType() == cmTarget::SHARED_LIBRARY ||
|
||||
this->GetType() == cmTarget::MODULE_LIBRARY) &&
|
||||
!this->GetPropertyAsBool("NO_SONAME") &&
|
||||
this->Makefile->GetSONameFlag(
|
||||
this->Target->GetLinkerLanguage(config)));
|
||||
this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config)));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -752,7 +751,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const
|
|||
}
|
||||
|
||||
// Check for rpath support on this platform.
|
||||
std::string ll = this->Target->GetLinkerLanguage(config);
|
||||
std::string ll = this->GetLinkerLanguage(config);
|
||||
if(!ll.empty())
|
||||
{
|
||||
std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
|
||||
|
@ -823,7 +822,7 @@ bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const
|
|||
#if defined(CMAKE_USE_ELF_PARSER)
|
||||
// Enable if the rpath flag uses a separator and the target uses ELF
|
||||
// binaries.
|
||||
std::string ll = this->Target->GetLinkerLanguage(config);
|
||||
std::string ll = this->GetLinkerLanguage(config);
|
||||
if(!ll.empty())
|
||||
{
|
||||
std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
|
||||
|
@ -1986,7 +1985,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config,
|
|||
const char* suffixVar = this->Target->GetSuffixVariableInternal(implib);
|
||||
|
||||
// Check for language-specific default prefix and suffix.
|
||||
std::string ll = this->Target->GetLinkerLanguage(config);
|
||||
std::string ll = this->GetLinkerLanguage(config);
|
||||
if(!ll.empty())
|
||||
{
|
||||
if(!targetSuffix && suffixVar && *suffixVar)
|
||||
|
@ -2055,6 +2054,13 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config,
|
|||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
std::string
|
||||
cmGeneratorTarget::GetLinkerLanguage(const std::string& config) const
|
||||
{
|
||||
return this->Target->GetLinkClosure(config)->LinkerLanguage;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
std::string cmGeneratorTarget::GetPDBName(const std::string& config) const
|
||||
{
|
||||
|
|
|
@ -258,6 +258,9 @@ public:
|
|||
/** Return true if builtin chrpath will work for this target */
|
||||
bool IsChrpathUsed(const std::string& config) const;
|
||||
|
||||
///! Return the preferred linker language for this target
|
||||
std::string GetLinkerLanguage(const std::string& config = "") const;
|
||||
|
||||
struct SourceFileFlags
|
||||
GetTargetSourceFileFlags(const cmSourceFile* sf) const;
|
||||
|
||||
|
|
|
@ -128,7 +128,8 @@ void cmGhsMultiTargetGenerator::Generate()
|
|||
{
|
||||
config = "RELEASE";
|
||||
}
|
||||
const std::string language(this->Target->GetLinkerLanguage(config));
|
||||
const std::string language(
|
||||
this->GeneratorTarget->GetLinkerLanguage(config));
|
||||
config = cmSystemTools::UpperCase(config);
|
||||
this->DynamicDownload = this->DetermineIfDynamicDownload(config, language);
|
||||
if (this->DynamicDownload)
|
||||
|
|
|
@ -1376,7 +1376,8 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget)
|
|||
return;
|
||||
}
|
||||
|
||||
std::string llang = cmtarget.GetLinkerLanguage("NOCONFIG");
|
||||
cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget);
|
||||
std::string llang = gtgt->GetLinkerLanguage("NOCONFIG");
|
||||
if(llang.empty()) { return; }
|
||||
|
||||
// If the language is compiled as a source trust Xcode to link with it.
|
||||
|
@ -1824,7 +1825,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
|
|||
AddCompileOptions(flags, &target, lang, configName);
|
||||
}
|
||||
|
||||
std::string llang = target.GetLinkerLanguage(configName);
|
||||
cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target);
|
||||
std::string llang = gtgt->GetLinkerLanguage(configName);
|
||||
if(binary && llang.empty())
|
||||
{
|
||||
cmSystemTools::Error
|
||||
|
@ -1850,7 +1852,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
|
|||
// Add the export symbol definition for shared library objects.
|
||||
this->AppendDefines(ppDefs, exportMacro);
|
||||
}
|
||||
cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target);
|
||||
std::vector<std::string> targetDefines;
|
||||
target.GetCompileDefinitions(targetDefines, configName, "C");
|
||||
this->AppendDefines(ppDefs, targetDefines);
|
||||
|
|
|
@ -1353,7 +1353,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
|
|||
linkFlags += this->Makefile->GetSafeDefinition(build);
|
||||
linkFlags += " ";
|
||||
}
|
||||
std::string linkLanguage = target->Target->GetLinkerLanguage(buildType);
|
||||
std::string linkLanguage = target->GetLinkerLanguage(buildType);
|
||||
if(linkLanguage.empty())
|
||||
{
|
||||
cmSystemTools::Error
|
||||
|
|
|
@ -1270,10 +1270,10 @@ void cmLocalVisualStudio6Generator
|
|||
std::vector<std::string> configs;
|
||||
target.GetMakefile()->GetConfigurations(configs);
|
||||
std::vector<std::string>::const_iterator it = configs.begin();
|
||||
const std::string& linkLanguage = target.GetLinkerLanguage(*it);
|
||||
const std::string& linkLanguage = gt->GetLinkerLanguage(*it);
|
||||
for ( ; it != configs.end(); ++it)
|
||||
{
|
||||
const std::string& configLinkLanguage = target.GetLinkerLanguage(*it);
|
||||
const std::string& configLinkLanguage = gt->GetLinkerLanguage(*it);
|
||||
if (configLinkLanguage != linkLanguage)
|
||||
{
|
||||
cmSystemTools::Error
|
||||
|
@ -1703,10 +1703,10 @@ void cmLocalVisualStudio6Generator
|
|||
std::vector<std::string> configs;
|
||||
target.GetMakefile()->GetConfigurations(configs);
|
||||
std::vector<std::string>::const_iterator it = configs.begin();
|
||||
const std::string& linkLanguage = target.GetLinkerLanguage(*it);
|
||||
const std::string& linkLanguage = gt->GetLinkerLanguage(*it);
|
||||
for ( ; it != configs.end(); ++it)
|
||||
{
|
||||
const std::string& configLinkLanguage = target.GetLinkerLanguage(*it);
|
||||
const std::string& configLinkLanguage = gt->GetLinkerLanguage(*it);
|
||||
if (configLinkLanguage != linkLanguage)
|
||||
{
|
||||
cmSystemTools::Error
|
||||
|
|
|
@ -664,6 +664,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
|
|||
const char* configType = "10";
|
||||
const char* projectType = 0;
|
||||
bool targetBuilds = true;
|
||||
|
||||
cmGeneratorTarget* gt =
|
||||
this->GlobalGenerator->GetGeneratorTarget(&target);
|
||||
|
||||
switch(target.GetType())
|
||||
{
|
||||
case cmTarget::OBJECT_LIBRARY:
|
||||
|
@ -696,7 +700,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
|
|||
{
|
||||
const std::string& linkLanguage = (this->FortranProject?
|
||||
std::string("Fortran"):
|
||||
target.GetLinkerLanguage(configName));
|
||||
gt->GetLinkerLanguage(configName));
|
||||
if(linkLanguage.empty())
|
||||
{
|
||||
cmSystemTools::Error
|
||||
|
@ -758,8 +762,6 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
|
|||
targetOptions.Parse(flags.c_str());
|
||||
targetOptions.Parse(defineFlags.c_str());
|
||||
targetOptions.ParseFinish();
|
||||
cmGeneratorTarget* gt =
|
||||
this->GlobalGenerator->GetGeneratorTarget(&target);
|
||||
std::vector<std::string> targetDefines;
|
||||
target.GetCompileDefinitions(targetDefines, configName, "CXX");
|
||||
targetOptions.AddDefines(targetDefines);
|
||||
|
@ -1635,7 +1637,7 @@ cmLocalVisualStudio7GeneratorFCInfo
|
|||
lg->GlobalGenerator->GetLanguageFromExtension
|
||||
(sf.GetExtension().c_str());
|
||||
const std::string& sourceLang = lg->GetSourceFileLanguage(sf);
|
||||
const std::string& linkLanguage = target.GetLinkerLanguage(i->c_str());
|
||||
const std::string& linkLanguage = gt->GetLinkerLanguage(i->c_str());
|
||||
bool needForceLang = false;
|
||||
// source file does not match its extension language
|
||||
if(lang != sourceLang)
|
||||
|
|
|
@ -161,7 +161,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
|
|||
|
||||
// Get the language to use for linking this executable.
|
||||
std::string linkLanguage =
|
||||
this->Target->GetLinkerLanguage(this->ConfigName);
|
||||
this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
|
||||
|
||||
// Make sure we have a link language.
|
||||
if(linkLanguage.empty())
|
||||
|
|
|
@ -133,7 +133,7 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules()
|
|||
void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules()
|
||||
{
|
||||
std::string linkLanguage =
|
||||
this->Target->GetLinkerLanguage(this->ConfigName);
|
||||
this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
|
||||
std::string linkRuleVar = "CMAKE_";
|
||||
linkRuleVar += linkLanguage;
|
||||
linkRuleVar += "_CREATE_STATIC_LIBRARY";
|
||||
|
@ -159,7 +159,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink)
|
|||
return;
|
||||
}
|
||||
std::string linkLanguage =
|
||||
this->Target->GetLinkerLanguage(this->ConfigName);
|
||||
this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
|
||||
std::string linkRuleVar = "CMAKE_";
|
||||
linkRuleVar += linkLanguage;
|
||||
linkRuleVar += "_CREATE_SHARED_LIBRARY";
|
||||
|
@ -183,7 +183,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink)
|
|||
void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink)
|
||||
{
|
||||
std::string linkLanguage =
|
||||
this->Target->GetLinkerLanguage(this->ConfigName);
|
||||
this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
|
||||
std::string linkRuleVar = "CMAKE_";
|
||||
linkRuleVar += linkLanguage;
|
||||
linkRuleVar += "_CREATE_SHARED_MODULE";
|
||||
|
@ -206,7 +206,7 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink)
|
|||
void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink)
|
||||
{
|
||||
std::string linkLanguage =
|
||||
this->Target->GetLinkerLanguage(this->ConfigName);
|
||||
this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
|
||||
std::string linkRuleVar = "CMAKE_";
|
||||
linkRuleVar += linkLanguage;
|
||||
linkRuleVar += "_CREATE_MACOSX_FRAMEWORK";
|
||||
|
@ -238,7 +238,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
|
|||
|
||||
// Get the language to use for linking this library.
|
||||
std::string linkLanguage =
|
||||
this->Target->GetLinkerLanguage(this->ConfigName);
|
||||
this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
|
||||
|
||||
// Make sure we have a link language.
|
||||
if(linkLanguage.empty())
|
||||
|
|
|
@ -1509,7 +1509,7 @@ std::string cmMakefileTargetGenerator::GetLinkRule(
|
|||
if(this->Target->HasImplibGNUtoMS())
|
||||
{
|
||||
std::string ruleVar = "CMAKE_";
|
||||
ruleVar += this->Target->GetLinkerLanguage(this->ConfigName);
|
||||
ruleVar += this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
|
||||
ruleVar += "_GNUtoMS_RULE";
|
||||
if(const char* rule = this->Makefile->GetDefinition(ruleVar))
|
||||
{
|
||||
|
@ -1663,7 +1663,8 @@ cmMakefileTargetGenerator
|
|||
{
|
||||
// Lookup the response file reference flag.
|
||||
std::string responseFlagVar = "CMAKE_";
|
||||
responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName);
|
||||
responseFlagVar += this->GeneratorTarget
|
||||
->GetLinkerLanguage(this->ConfigName);
|
||||
responseFlagVar += "_RESPONSE_FILE_LINK_FLAG";
|
||||
const char* responseFlag =
|
||||
this->Makefile->GetDefinition(responseFlagVar);
|
||||
|
@ -1707,7 +1708,8 @@ cmMakefileTargetGenerator
|
|||
|
||||
// Lookup the response file reference flag.
|
||||
std::string responseFlagVar = "CMAKE_";
|
||||
responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName);
|
||||
responseFlagVar += this->GeneratorTarget
|
||||
->GetLinkerLanguage(this->ConfigName);
|
||||
responseFlagVar += "_RESPONSE_FILE_LINK_FLAG";
|
||||
const char* responseFlag =
|
||||
this->Makefile->GetDefinition(responseFlagVar);
|
||||
|
|
|
@ -40,8 +40,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target)
|
|||
, TargetNamePDB()
|
||||
, TargetLinkLanguage("")
|
||||
{
|
||||
this->TargetLinkLanguage = target->Target
|
||||
->GetLinkerLanguage(this->GetConfigName());
|
||||
this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName());
|
||||
if (target->GetType() == cmTarget::EXECUTABLE)
|
||||
this->GetGeneratorTarget()->GetExecutableNames(this->TargetNameOut,
|
||||
this->TargetNameReal,
|
||||
|
|
|
@ -3217,12 +3217,6 @@ private:
|
|||
std::set<cmTarget const*> Visited;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
std::string cmTarget::GetLinkerLanguage(const std::string& config) const
|
||||
{
|
||||
return this->GetLinkClosure(config)->LinkerLanguage;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
cmTarget::LinkClosure const*
|
||||
cmTarget::GetLinkClosure(const std::string& config) const
|
||||
|
|
|
@ -365,9 +365,6 @@ public:
|
|||
void
|
||||
GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const;
|
||||
|
||||
///! Return the preferred linker language for this target
|
||||
std::string GetLinkerLanguage(const std::string& config = "") const;
|
||||
|
||||
/** Whether this library has \@rpath and platform supports it. */
|
||||
bool HasMacOSXRpathInstallNameDir(const std::string& config) const;
|
||||
|
||||
|
|
|
@ -1627,7 +1627,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
|
|||
this->GlobalGenerator->GetLanguageFromExtension
|
||||
(sf.GetExtension().c_str());
|
||||
std::string sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf);
|
||||
const std::string& linkLanguage = this->Target->GetLinkerLanguage();
|
||||
const std::string& linkLanguage = this->GeneratorTarget->GetLinkerLanguage();
|
||||
bool needForceLang = false;
|
||||
// source file does not match its extension language
|
||||
if(lang != sourceLang)
|
||||
|
@ -1888,7 +1888,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
|
|||
|
||||
std::string flags;
|
||||
const std::string& linkLanguage =
|
||||
this->Target->GetLinkerLanguage(configName.c_str());
|
||||
this->GeneratorTarget->GetLinkerLanguage(configName.c_str());
|
||||
if(linkLanguage.empty())
|
||||
{
|
||||
cmSystemTools::Error
|
||||
|
@ -2371,7 +2371,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
|
|||
Options& linkOptions = *pOptions;
|
||||
|
||||
const std::string& linkLanguage =
|
||||
this->Target->GetLinkerLanguage(config.c_str());
|
||||
this->GeneratorTarget->GetLinkerLanguage(config.c_str());
|
||||
if(linkLanguage.empty())
|
||||
{
|
||||
cmSystemTools::Error
|
||||
|
|
Loading…
Reference in New Issue