From a60846718048e33db01e7993ba7d6fa994e0c8b5 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 7 Jul 2009 07:44:12 -0400 Subject: 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. --- Source/cmComputeLinkInformation.cxx | 3 +-- Source/cmGlobalXCodeGenerator.cxx | 4 ++-- Source/cmLocalGenerator.cxx | 6 ++---- Source/cmLocalVisualStudio6Generator.cxx | 6 ++---- Source/cmLocalVisualStudio7Generator.cxx | 6 ++---- Source/cmMakefileExecutableTargetGenerator.cxx | 3 +-- Source/cmMakefileLibraryTargetGenerator.cxx | 15 +++++---------- Source/cmTarget.cxx | 18 +++++++----------- Source/cmTarget.h | 2 +- Source/cmVisualStudio10TargetGenerator.cxx | 12 ++++-------- 10 files changed, 27 insertions(+), 48 deletions(-) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 03b8571..7be0d85 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -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 diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 01c587a..3437d22 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -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) { diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index f66988e..c6fd8db 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -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 diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index faf6792..c2b5a7c 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -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 diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index f009657..7ca3f8c 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -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) diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 4e5c382..cebdf59 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -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) diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 8752702..00935b8 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -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) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ca64402..5883274 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -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(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; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index fabf7cf..a3e2439 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -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. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index cd96a75..bae892d 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -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 -- cgit v0.12