From 173448d9886deccb7cadd4fd0ffeaa236fa66e49 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 8 Jul 2009 13:04:04 -0400 Subject: [PATCH] ENH: Pass config to cmTarget::GetLinkerLanguage This passes the build configuration to most GetLinkerLanguage calls. In the future the linker language will account for targets linked in each configuration. --- Source/cmComputeLinkInformation.cxx | 2 +- Source/cmGlobalXCodeGenerator.cxx | 2 +- Source/cmLocalVisualStudio7Generator.cxx | 4 ++-- Source/cmMakefileExecutableTargetGenerator.cxx | 3 ++- Source/cmMakefileLibraryTargetGenerator.cxx | 15 ++++++++++----- Source/cmTarget.cxx | 8 ++++---- Source/cmTarget.h | 2 +- Source/cmVisualStudio10TargetGenerator.cxx | 9 ++++++--- 8 files changed, 27 insertions(+), 18 deletions(-) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 4ca68173e..66d355db8 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -264,7 +264,7 @@ cmComputeLinkInformation this->OrderDependentRPath = 0; // Get the language used for linking this target. - this->LinkLanguage = this->Target->GetLinkerLanguage(); + this->LinkLanguage = this->Target->GetLinkerLanguage(config); 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 3d5291aa9..5f22946c3 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1378,7 +1378,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, bool shared = ((target.GetType() == cmTarget::SHARED_LIBRARY) || (target.GetType() == cmTarget::MODULE_LIBRARY)); - const char* lang = target.GetLinkerLanguage(); + const char* lang = target.GetLinkerLanguage(configName); std::string cflags; if(lang) { diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 7ca3f8c5f..7fb04b108 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -656,7 +656,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, std::string flags; if(strcmp(configType, "10") != 0) { - const char* linkLanguage = target.GetLinkerLanguage(); + const char* linkLanguage = target.GetLinkerLanguage(configName); if(!linkLanguage) { cmSystemTools::Error @@ -1362,7 +1362,7 @@ cmLocalVisualStudio7GeneratorFCInfo lg->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); const char* sourceLang = lg->GetSourceFileLanguage(sf); - const char* linkLanguage = target.GetLinkerLanguage(); + const char* linkLanguage = target.GetLinkerLanguage(i->c_str()); 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 e9ac80c77..c269afcbb 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -178,7 +178,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) cmLocalGenerator::SHELL); // Get the language to use for linking this executable. - const char* linkLanguage = this->Target->GetLinkerLanguage(); + const char* linkLanguage = + this->Target->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. if(!linkLanguage) diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 9c9282446..9a5f7fd45 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -109,7 +109,8 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() //---------------------------------------------------------------------------- void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules() { - const char* linkLanguage = this->Target->GetLinkerLanguage(); + const char* linkLanguage = + this->Target->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; if (linkLanguage) { @@ -131,7 +132,8 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) this->WriteFrameworkRules(relink); return; } - const char* linkLanguage = this->Target->GetLinkerLanguage(); + const char* linkLanguage = + this->Target->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; if (linkLanguage) { @@ -176,7 +178,8 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) //---------------------------------------------------------------------------- void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) { - const char* linkLanguage = this->Target->GetLinkerLanguage(); + const char* linkLanguage = + this->Target->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; if (linkLanguage) { @@ -201,7 +204,8 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) //---------------------------------------------------------------------------- void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink) { - const char* linkLanguage = this->Target->GetLinkerLanguage(); + const char* linkLanguage = + this->Target->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; if (linkLanguage) { @@ -347,7 +351,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules } // Get the language to use for linking this library. - const char* linkLanguage = this->Target->GetLinkerLanguage(); + const char* linkLanguage = + this->Target->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. if(!linkLanguage) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 400319072..32c16880e 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2320,7 +2320,7 @@ bool cmTarget::GetPropertyAsBool(const char* prop) } //---------------------------------------------------------------------------- -const char* cmTarget::GetLinkerLanguage() +const char* cmTarget::GetLinkerLanguage(const char*) { cmGlobalGenerator* gg = this->Makefile->GetLocalGenerator()->GetGlobalGenerator(); @@ -2772,7 +2772,7 @@ void cmTarget::GetLibraryNames(std::string& name, } // Construct the name of the soname flag variable for this language. - const char* ll = this->GetLinkerLanguage(); + const char* ll = this->GetLinkerLanguage(config); std::string sonameFlag = "CMAKE_SHARED_LIBRARY_SONAME"; if(ll) { @@ -3062,7 +3062,7 @@ bool cmTarget::NeedRelinkBeforeInstall(const char* config) } // Check for rpath support on this platform. - if(const char* ll = this->GetLinkerLanguage()) + if(const char* ll = this->GetLinkerLanguage(config)) { std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; flagVar += ll; @@ -3387,7 +3387,7 @@ bool cmTarget::IsChrpathUsed(const char* config) // Enable if the rpath flag uses a separator and the target uses ELF // binaries. - if(const char* ll = this->GetLinkerLanguage()) + if(const char* ll = this->GetLinkerLanguage(config)) { std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; sepVar += ll; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 4ce6b307d..63e85169c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -305,7 +305,7 @@ public: bool FindSourceFiles(); ///! Return the prefered linker language for this target - const char* GetLinkerLanguage(); + const char* GetLinkerLanguage(const char* config = 0); ///! 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 bae892d5a..065f454e1 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -582,7 +582,8 @@ OutputLinkIncremental(std::string const& configName) // assume incremental linking const char* incremental = "true"; - const char* linkLanguage = this->Target->GetLinkerLanguage(); + const char* linkLanguage = + this->Target->GetLinkerLanguage(configName.c_str()); if(!linkLanguage) { cmSystemTools::Error @@ -638,7 +639,8 @@ WriteClOptions(std::string const& configName, // collect up flags for if(this->Target->GetType() < cmTarget::UTILITY) { - const char* linkLanguage = this->Target->GetLinkerLanguage(); + const char* linkLanguage = + this->Target->GetLinkerLanguage(configName.c_str()); if(!linkLanguage) { cmSystemTools::Error @@ -772,7 +774,8 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& { return; } - const char* linkLanguage = this->Target->GetLinkerLanguage(); + const char* linkLanguage = + this->Target->GetLinkerLanguage(config.c_str()); if(!linkLanguage) { cmSystemTools::Error