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.
This commit is contained in:
parent
6ec20cc3f9
commit
a608467180
|
@ -264,8 +264,7 @@ cmComputeLinkInformation
|
||||||
this->OrderDependentRPath = 0;
|
this->OrderDependentRPath = 0;
|
||||||
|
|
||||||
// Get the language used for linking this target.
|
// Get the language used for linking this target.
|
||||||
this->LinkLanguage =
|
this->LinkLanguage = this->Target->GetLinkerLanguage();
|
||||||
this->Target->GetLinkerLanguage(this->GlobalGenerator);
|
|
||||||
if(!this->LinkLanguage)
|
if(!this->LinkLanguage)
|
||||||
{
|
{
|
||||||
// The Compute method will do nothing, so skip the rest of the
|
// 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")
|
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"))
|
if(linkLanguage && (std::string(linkLanguage) == "CXX"))
|
||||||
{
|
{
|
||||||
sourcecode += ".cpp.h";
|
sourcecode += ".cpp.h";
|
||||||
|
@ -1382,7 +1382,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
|
||||||
bool shared = ((target.GetType() == cmTarget::SHARED_LIBRARY) ||
|
bool shared = ((target.GetType() == cmTarget::SHARED_LIBRARY) ||
|
||||||
(target.GetType() == cmTarget::MODULE_LIBRARY));
|
(target.GetType() == cmTarget::MODULE_LIBRARY));
|
||||||
|
|
||||||
const char* lang = target.GetLinkerLanguage(this);
|
const char* lang = target.GetLinkerLanguage();
|
||||||
std::string cflags;
|
std::string cflags;
|
||||||
if(lang)
|
if(lang)
|
||||||
{
|
{
|
||||||
|
|
|
@ -697,8 +697,7 @@ void cmLocalGenerator
|
||||||
case cmTarget::MODULE_LIBRARY:
|
case cmTarget::MODULE_LIBRARY:
|
||||||
case cmTarget::EXECUTABLE:
|
case cmTarget::EXECUTABLE:
|
||||||
{
|
{
|
||||||
const char* llang =
|
const char* llang = target.GetLinkerLanguage();
|
||||||
target.GetLinkerLanguage(this->GetGlobalGenerator());
|
|
||||||
if(!llang)
|
if(!llang)
|
||||||
{
|
{
|
||||||
cmSystemTools::Error
|
cmSystemTools::Error
|
||||||
|
@ -1455,8 +1454,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
|
||||||
linkFlags += this->Makefile->GetSafeDefinition(build.c_str());
|
linkFlags += this->Makefile->GetSafeDefinition(build.c_str());
|
||||||
linkFlags += " ";
|
linkFlags += " ";
|
||||||
}
|
}
|
||||||
const char* linkLanguage =
|
const char* linkLanguage = target.GetLinkerLanguage();
|
||||||
target.GetLinkerLanguage(this->GetGlobalGenerator());
|
|
||||||
if(!linkLanguage)
|
if(!linkLanguage)
|
||||||
{
|
{
|
||||||
cmSystemTools::Error
|
cmSystemTools::Error
|
||||||
|
|
|
@ -1138,8 +1138,7 @@ void cmLocalVisualStudio6Generator
|
||||||
if(targetBuilds)
|
if(targetBuilds)
|
||||||
{
|
{
|
||||||
// Get the language to use for linking.
|
// Get the language to use for linking.
|
||||||
const char* linkLanguage =
|
const char* linkLanguage = target.GetLinkerLanguage();
|
||||||
target.GetLinkerLanguage(this->GetGlobalGenerator());
|
|
||||||
if(!linkLanguage)
|
if(!linkLanguage)
|
||||||
{
|
{
|
||||||
cmSystemTools::Error
|
cmSystemTools::Error
|
||||||
|
@ -1438,8 +1437,7 @@ void cmLocalVisualStudio6Generator
|
||||||
if(target.GetType() >= cmTarget::EXECUTABLE &&
|
if(target.GetType() >= cmTarget::EXECUTABLE &&
|
||||||
target.GetType() <= cmTarget::MODULE_LIBRARY)
|
target.GetType() <= cmTarget::MODULE_LIBRARY)
|
||||||
{
|
{
|
||||||
const char* linkLanguage =
|
const char* linkLanguage = target.GetLinkerLanguage();
|
||||||
target.GetLinkerLanguage(this->GetGlobalGenerator());
|
|
||||||
if(!linkLanguage)
|
if(!linkLanguage)
|
||||||
{
|
{
|
||||||
cmSystemTools::Error
|
cmSystemTools::Error
|
||||||
|
|
|
@ -656,8 +656,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
|
||||||
std::string flags;
|
std::string flags;
|
||||||
if(strcmp(configType, "10") != 0)
|
if(strcmp(configType, "10") != 0)
|
||||||
{
|
{
|
||||||
const char* linkLanguage =
|
const char* linkLanguage = target.GetLinkerLanguage();
|
||||||
target.GetLinkerLanguage(this->GetGlobalGenerator());
|
|
||||||
if(!linkLanguage)
|
if(!linkLanguage)
|
||||||
{
|
{
|
||||||
cmSystemTools::Error
|
cmSystemTools::Error
|
||||||
|
@ -1363,8 +1362,7 @@ cmLocalVisualStudio7GeneratorFCInfo
|
||||||
lg->GlobalGenerator->GetLanguageFromExtension
|
lg->GlobalGenerator->GetLanguageFromExtension
|
||||||
(sf.GetExtension().c_str());
|
(sf.GetExtension().c_str());
|
||||||
const char* sourceLang = lg->GetSourceFileLanguage(sf);
|
const char* sourceLang = lg->GetSourceFileLanguage(sf);
|
||||||
const char* linkLanguage = target.GetLinkerLanguage
|
const char* linkLanguage = target.GetLinkerLanguage();
|
||||||
(lg->GetGlobalGenerator());
|
|
||||||
bool needForceLang = false;
|
bool needForceLang = false;
|
||||||
// source file does not match its extension language
|
// source file does not match its extension language
|
||||||
if(lang && sourceLang && strcmp(lang, sourceLang) != 0)
|
if(lang && sourceLang && strcmp(lang, sourceLang) != 0)
|
||||||
|
|
|
@ -178,8 +178,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
|
||||||
cmLocalGenerator::SHELL);
|
cmLocalGenerator::SHELL);
|
||||||
|
|
||||||
// Get the language to use for linking this executable.
|
// Get the language to use for linking this executable.
|
||||||
const char* linkLanguage =
|
const char* linkLanguage = this->Target->GetLinkerLanguage();
|
||||||
this->Target->GetLinkerLanguage(this->GlobalGenerator);
|
|
||||||
|
|
||||||
// Make sure we have a link language.
|
// Make sure we have a link language.
|
||||||
if(!linkLanguage)
|
if(!linkLanguage)
|
||||||
|
|
|
@ -109,8 +109,7 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles()
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules()
|
void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules()
|
||||||
{
|
{
|
||||||
const char* linkLanguage =
|
const char* linkLanguage = this->Target->GetLinkerLanguage();
|
||||||
this->Target->GetLinkerLanguage(this->GlobalGenerator);
|
|
||||||
std::string linkRuleVar = "CMAKE_";
|
std::string linkRuleVar = "CMAKE_";
|
||||||
if (linkLanguage)
|
if (linkLanguage)
|
||||||
{
|
{
|
||||||
|
@ -132,8 +131,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink)
|
||||||
this->WriteFrameworkRules(relink);
|
this->WriteFrameworkRules(relink);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const char* linkLanguage =
|
const char* linkLanguage = this->Target->GetLinkerLanguage();
|
||||||
this->Target->GetLinkerLanguage(this->GlobalGenerator);
|
|
||||||
std::string linkRuleVar = "CMAKE_";
|
std::string linkRuleVar = "CMAKE_";
|
||||||
if (linkLanguage)
|
if (linkLanguage)
|
||||||
{
|
{
|
||||||
|
@ -178,8 +176,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink)
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink)
|
void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink)
|
||||||
{
|
{
|
||||||
const char* linkLanguage =
|
const char* linkLanguage = this->Target->GetLinkerLanguage();
|
||||||
this->Target->GetLinkerLanguage(this->GlobalGenerator);
|
|
||||||
std::string linkRuleVar = "CMAKE_";
|
std::string linkRuleVar = "CMAKE_";
|
||||||
if (linkLanguage)
|
if (linkLanguage)
|
||||||
{
|
{
|
||||||
|
@ -204,8 +201,7 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink)
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink)
|
void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink)
|
||||||
{
|
{
|
||||||
const char* linkLanguage =
|
const char* linkLanguage = this->Target->GetLinkerLanguage();
|
||||||
this->Target->GetLinkerLanguage(this->GlobalGenerator);
|
|
||||||
std::string linkRuleVar = "CMAKE_";
|
std::string linkRuleVar = "CMAKE_";
|
||||||
if (linkLanguage)
|
if (linkLanguage)
|
||||||
{
|
{
|
||||||
|
@ -351,8 +347,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the language to use for linking this library.
|
// Get the language to use for linking this library.
|
||||||
const char* linkLanguage =
|
const char* linkLanguage = this->Target->GetLinkerLanguage();
|
||||||
this->Target->GetLinkerLanguage(this->GlobalGenerator);
|
|
||||||
|
|
||||||
// Make sure we have a link language.
|
// Make sure we have a link language.
|
||||||
if(!linkLanguage)
|
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"))
|
if(this->GetProperty("HAS_CXX"))
|
||||||
{
|
{
|
||||||
const_cast<cmTarget*>(this)->SetProperty("LINKER_LANGUAGE", "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* prefixVar = this->GetPrefixVariableInternal(implib);
|
||||||
const char* suffixVar = this->GetSuffixVariableInternal(implib);
|
const char* suffixVar = this->GetSuffixVariableInternal(implib);
|
||||||
const char* ll =
|
const char* ll = this->GetLinkerLanguage();
|
||||||
this->GetLinkerLanguage(
|
|
||||||
this->Makefile->GetLocalGenerator()->GetGlobalGenerator());
|
|
||||||
// first try language specific suffix
|
// first try language specific suffix
|
||||||
if(ll)
|
if(ll)
|
||||||
{
|
{
|
||||||
|
@ -2750,9 +2750,7 @@ void cmTarget::GetLibraryNames(std::string& name,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct the name of the soname flag variable for this language.
|
// Construct the name of the soname flag variable for this language.
|
||||||
const char* ll =
|
const char* ll = this->GetLinkerLanguage();
|
||||||
this->GetLinkerLanguage(
|
|
||||||
this->Makefile->GetLocalGenerator()->GetGlobalGenerator());
|
|
||||||
std::string sonameFlag = "CMAKE_SHARED_LIBRARY_SONAME";
|
std::string sonameFlag = "CMAKE_SHARED_LIBRARY_SONAME";
|
||||||
if(ll)
|
if(ll)
|
||||||
{
|
{
|
||||||
|
@ -3042,8 +3040,7 @@ bool cmTarget::NeedRelinkBeforeInstall()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for rpath support on this platform.
|
// Check for rpath support on this platform.
|
||||||
if(const char* ll = this->GetLinkerLanguage(
|
if(const char* ll = this->GetLinkerLanguage())
|
||||||
this->Makefile->GetLocalGenerator()->GetGlobalGenerator()))
|
|
||||||
{
|
{
|
||||||
std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
|
std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
|
||||||
flagVar += ll;
|
flagVar += ll;
|
||||||
|
@ -3368,8 +3365,7 @@ bool cmTarget::IsChrpathUsed()
|
||||||
|
|
||||||
// Enable if the rpath flag uses a separator and the target uses ELF
|
// Enable if the rpath flag uses a separator and the target uses ELF
|
||||||
// binaries.
|
// binaries.
|
||||||
if(const char* ll = this->GetLinkerLanguage(
|
if(const char* ll = this->GetLinkerLanguage())
|
||||||
this->Makefile->GetLocalGenerator()->GetGlobalGenerator()))
|
|
||||||
{
|
{
|
||||||
std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
|
std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
|
||||||
sepVar += ll;
|
sepVar += ll;
|
||||||
|
|
|
@ -301,7 +301,7 @@ public:
|
||||||
bool FindSourceFiles();
|
bool FindSourceFiles();
|
||||||
|
|
||||||
///! Return the prefered linker language for this target
|
///! 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,
|
///! Return the rule variable used to create this type of target,
|
||||||
// need to add CMAKE_(LANG) for full name.
|
// need to add CMAKE_(LANG) for full name.
|
||||||
|
|
|
@ -446,8 +446,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
|
||||||
this->GlobalGenerator->GetLanguageFromExtension
|
this->GlobalGenerator->GetLanguageFromExtension
|
||||||
(sf.GetExtension().c_str());
|
(sf.GetExtension().c_str());
|
||||||
const char* sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf);
|
const char* sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf);
|
||||||
const char* linkLanguage = this->Target->GetLinkerLanguage
|
const char* linkLanguage = this->Target->GetLinkerLanguage();
|
||||||
(this->LocalGenerator->GetGlobalGenerator());
|
|
||||||
bool needForceLang = false;
|
bool needForceLang = false;
|
||||||
// source file does not match its extension language
|
// source file does not match its extension language
|
||||||
if(lang && sourceLang && strcmp(lang, sourceLang) != 0)
|
if(lang && sourceLang && strcmp(lang, sourceLang) != 0)
|
||||||
|
@ -583,8 +582,7 @@ OutputLinkIncremental(std::string const& configName)
|
||||||
|
|
||||||
// assume incremental linking
|
// assume incremental linking
|
||||||
const char* incremental = "true";
|
const char* incremental = "true";
|
||||||
const char* linkLanguage =
|
const char* linkLanguage = this->Target->GetLinkerLanguage();
|
||||||
this->Target->GetLinkerLanguage(this->GlobalGenerator);
|
|
||||||
if(!linkLanguage)
|
if(!linkLanguage)
|
||||||
{
|
{
|
||||||
cmSystemTools::Error
|
cmSystemTools::Error
|
||||||
|
@ -640,8 +638,7 @@ WriteClOptions(std::string const& configName,
|
||||||
// collect up flags for
|
// collect up flags for
|
||||||
if(this->Target->GetType() < cmTarget::UTILITY)
|
if(this->Target->GetType() < cmTarget::UTILITY)
|
||||||
{
|
{
|
||||||
const char* linkLanguage =
|
const char* linkLanguage = this->Target->GetLinkerLanguage();
|
||||||
this->Target->GetLinkerLanguage(this->GlobalGenerator);
|
|
||||||
if(!linkLanguage)
|
if(!linkLanguage)
|
||||||
{
|
{
|
||||||
cmSystemTools::Error
|
cmSystemTools::Error
|
||||||
|
@ -775,8 +772,7 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const&
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const char* linkLanguage =
|
const char* linkLanguage = this->Target->GetLinkerLanguage();
|
||||||
this->Target->GetLinkerLanguage(this->GlobalGenerator);
|
|
||||||
if(!linkLanguage)
|
if(!linkLanguage)
|
||||||
{
|
{
|
||||||
cmSystemTools::Error
|
cmSystemTools::Error
|
||||||
|
|
Loading…
Reference in New Issue