Commit a6084671 authored by Brad King's avatar Brad King
Browse files

ENH: Simpler cmTarget::GetLinkerLanguage signature

This method previously required the global generator to be passed, but
that was left from before cmTarget had its Makefile member.  Now the
global generator can be retrieved automatically, so we can drop the
method argument.
parent 6ec20cc3
......@@ -264,8 +264,7 @@ cmComputeLinkInformation
this->OrderDependentRPath = 0;
// Get the language used for linking this target.
this->LinkLanguage =
this->Target->GetLinkerLanguage(this->GlobalGenerator);
this->LinkLanguage = this->Target->GetLinkerLanguage();
if(!this->LinkLanguage)
{
// The Compute method will do nothing, so skip the rest of the
......
......@@ -635,7 +635,7 @@ cmGlobalXCodeGenerator::CreateXCodeFileReference(cmSourceFile* sf,
}
else if(ext == "h" || ext == "hxx" || ext == "hpp")
{
const char* linkLanguage = cmtarget.GetLinkerLanguage(this);
const char* linkLanguage = cmtarget.GetLinkerLanguage();
if(linkLanguage && (std::string(linkLanguage) == "CXX"))
{
sourcecode += ".cpp.h";
......@@ -1382,7 +1382,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
bool shared = ((target.GetType() == cmTarget::SHARED_LIBRARY) ||
(target.GetType() == cmTarget::MODULE_LIBRARY));
const char* lang = target.GetLinkerLanguage(this);
const char* lang = target.GetLinkerLanguage();
std::string cflags;
if(lang)
{
......
......@@ -697,8 +697,7 @@ void cmLocalGenerator
case cmTarget::MODULE_LIBRARY:
case cmTarget::EXECUTABLE:
{
const char* llang =
target.GetLinkerLanguage(this->GetGlobalGenerator());
const char* llang = target.GetLinkerLanguage();
if(!llang)
{
cmSystemTools::Error
......@@ -1455,8 +1454,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
linkFlags += this->Makefile->GetSafeDefinition(build.c_str());
linkFlags += " ";
}
const char* linkLanguage =
target.GetLinkerLanguage(this->GetGlobalGenerator());
const char* linkLanguage = target.GetLinkerLanguage();
if(!linkLanguage)
{
cmSystemTools::Error
......
......@@ -1138,8 +1138,7 @@ void cmLocalVisualStudio6Generator
if(targetBuilds)
{
// Get the language to use for linking.
const char* linkLanguage =
target.GetLinkerLanguage(this->GetGlobalGenerator());
const char* linkLanguage = target.GetLinkerLanguage();
if(!linkLanguage)
{
cmSystemTools::Error
......@@ -1438,8 +1437,7 @@ void cmLocalVisualStudio6Generator
if(target.GetType() >= cmTarget::EXECUTABLE &&
target.GetType() <= cmTarget::MODULE_LIBRARY)
{
const char* linkLanguage =
target.GetLinkerLanguage(this->GetGlobalGenerator());
const char* linkLanguage = target.GetLinkerLanguage();
if(!linkLanguage)
{
cmSystemTools::Error
......
......@@ -656,8 +656,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
std::string flags;
if(strcmp(configType, "10") != 0)
{
const char* linkLanguage =
target.GetLinkerLanguage(this->GetGlobalGenerator());
const char* linkLanguage = target.GetLinkerLanguage();
if(!linkLanguage)
{
cmSystemTools::Error
......@@ -1363,8 +1362,7 @@ cmLocalVisualStudio7GeneratorFCInfo
lg->GlobalGenerator->GetLanguageFromExtension
(sf.GetExtension().c_str());
const char* sourceLang = lg->GetSourceFileLanguage(sf);
const char* linkLanguage = target.GetLinkerLanguage
(lg->GetGlobalGenerator());
const char* linkLanguage = target.GetLinkerLanguage();
bool needForceLang = false;
// source file does not match its extension language
if(lang && sourceLang && strcmp(lang, sourceLang) != 0)
......
......@@ -178,8 +178,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
cmLocalGenerator::SHELL);
// Get the language to use for linking this executable.
const char* linkLanguage =
this->Target->GetLinkerLanguage(this->GlobalGenerator);
const char* linkLanguage = this->Target->GetLinkerLanguage();
// Make sure we have a link language.
if(!linkLanguage)
......
......@@ -109,8 +109,7 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles()
//----------------------------------------------------------------------------
void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules()
{
const char* linkLanguage =
this->Target->GetLinkerLanguage(this->GlobalGenerator);
const char* linkLanguage = this->Target->GetLinkerLanguage();
std::string linkRuleVar = "CMAKE_";
if (linkLanguage)
{
......@@ -132,8 +131,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink)
this->WriteFrameworkRules(relink);
return;
}
const char* linkLanguage =
this->Target->GetLinkerLanguage(this->GlobalGenerator);
const char* linkLanguage = this->Target->GetLinkerLanguage();
std::string linkRuleVar = "CMAKE_";
if (linkLanguage)
{
......@@ -178,8 +176,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink)
//----------------------------------------------------------------------------
void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink)
{
const char* linkLanguage =
this->Target->GetLinkerLanguage(this->GlobalGenerator);
const char* linkLanguage = this->Target->GetLinkerLanguage();
std::string linkRuleVar = "CMAKE_";
if (linkLanguage)
{
......@@ -204,8 +201,7 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink)
//----------------------------------------------------------------------------
void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink)
{
const char* linkLanguage =
this->Target->GetLinkerLanguage(this->GlobalGenerator);
const char* linkLanguage = this->Target->GetLinkerLanguage();
std::string linkRuleVar = "CMAKE_";
if (linkLanguage)
{
......@@ -351,8 +347,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
}
// Get the language to use for linking this library.
const char* linkLanguage =
this->Target->GetLinkerLanguage(this->GlobalGenerator);
const char* linkLanguage = this->Target->GetLinkerLanguage();
// Make sure we have a link language.
if(!linkLanguage)
......
......@@ -2283,8 +2283,10 @@ bool cmTarget::GetPropertyAsBool(const char* prop)
}
//----------------------------------------------------------------------------
const char* cmTarget::GetLinkerLanguage(cmGlobalGenerator* gg)
const char* cmTarget::GetLinkerLanguage()
{
cmGlobalGenerator* gg =
this->Makefile->GetLocalGenerator()->GetGlobalGenerator();
if(this->GetProperty("HAS_CXX"))
{
const_cast<cmTarget*>(this)->SetProperty("LINKER_LANGUAGE", "CXX");
......@@ -2669,9 +2671,7 @@ void cmTarget::GetFullNameInternal(const char* config,
}
const char* prefixVar = this->GetPrefixVariableInternal(implib);
const char* suffixVar = this->GetSuffixVariableInternal(implib);
const char* ll =
this->GetLinkerLanguage(
this->Makefile->GetLocalGenerator()->GetGlobalGenerator());
const char* ll = this->GetLinkerLanguage();
// first try language specific suffix
if(ll)
{
......@@ -2750,9 +2750,7 @@ void cmTarget::GetLibraryNames(std::string& name,
}
// Construct the name of the soname flag variable for this language.
const char* ll =
this->GetLinkerLanguage(
this->Makefile->GetLocalGenerator()->GetGlobalGenerator());
const char* ll = this->GetLinkerLanguage();
std::string sonameFlag = "CMAKE_SHARED_LIBRARY_SONAME";
if(ll)
{
......@@ -3042,8 +3040,7 @@ bool cmTarget::NeedRelinkBeforeInstall()
}
// Check for rpath support on this platform.
if(const char* ll = this->GetLinkerLanguage(
this->Makefile->GetLocalGenerator()->GetGlobalGenerator()))
if(const char* ll = this->GetLinkerLanguage())
{
std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
flagVar += ll;
......@@ -3368,8 +3365,7 @@ bool cmTarget::IsChrpathUsed()
// Enable if the rpath flag uses a separator and the target uses ELF
// binaries.
if(const char* ll = this->GetLinkerLanguage(
this->Makefile->GetLocalGenerator()->GetGlobalGenerator()))
if(const char* ll = this->GetLinkerLanguage())
{
std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
sepVar += ll;
......
......@@ -301,7 +301,7 @@ public:
bool FindSourceFiles();
///! Return the prefered linker language for this target
const char* GetLinkerLanguage(cmGlobalGenerator*);
const char* GetLinkerLanguage();
///! Return the rule variable used to create this type of target,
// need to add CMAKE_(LANG) for full name.
......
......@@ -446,8 +446,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
this->GlobalGenerator->GetLanguageFromExtension
(sf.GetExtension().c_str());
const char* sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf);
const char* linkLanguage = this->Target->GetLinkerLanguage
(this->LocalGenerator->GetGlobalGenerator());
const char* linkLanguage = this->Target->GetLinkerLanguage();
bool needForceLang = false;
// source file does not match its extension language
if(lang && sourceLang && strcmp(lang, sourceLang) != 0)
......@@ -583,8 +582,7 @@ OutputLinkIncremental(std::string const& configName)
// assume incremental linking
const char* incremental = "true";
const char* linkLanguage =
this->Target->GetLinkerLanguage(this->GlobalGenerator);
const char* linkLanguage = this->Target->GetLinkerLanguage();
if(!linkLanguage)
{
cmSystemTools::Error
......@@ -640,8 +638,7 @@ WriteClOptions(std::string const& configName,
// collect up flags for
if(this->Target->GetType() < cmTarget::UTILITY)
{
const char* linkLanguage =
this->Target->GetLinkerLanguage(this->GlobalGenerator);
const char* linkLanguage = this->Target->GetLinkerLanguage();
if(!linkLanguage)
{
cmSystemTools::Error
......@@ -775,8 +772,7 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const&
{
return;
}
const char* linkLanguage =
this->Target->GetLinkerLanguage(this->GlobalGenerator);
const char* linkLanguage = this->Target->GetLinkerLanguage();
if(!linkLanguage)
{
cmSystemTools::Error
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment