From 5d12b87b9d505b8c9d0d4363e33636078c7510e7 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 21 May 2014 09:38:24 -0400 Subject: cmGeneratorTarget: Improve GetCreateRuleVariable API Pass the language and configuration to the method so it can return the complete rule variable name. --- Source/cmGeneratorTarget.cxx | 12 +++++++----- Source/cmGeneratorTarget.h | 6 +++--- Source/cmLocalGenerator.cxx | 8 +++----- Source/cmNinjaNormalTargetGenerator.cxx | 10 +++++----- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index ec5ce9e..20f2d96 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -943,18 +943,20 @@ void cmGeneratorTarget::GetAppleArchs(const std::string& config, } //---------------------------------------------------------------------------- -const char* cmGeneratorTarget::GetCreateRuleVariable() const +std::string +cmGeneratorTarget::GetCreateRuleVariable(std::string const& lang, + std::string const&) const { switch(this->GetType()) { case cmTarget::STATIC_LIBRARY: - return "_CREATE_STATIC_LIBRARY"; + return "CMAKE_" + lang + "_CREATE_STATIC_LIBRARY"; case cmTarget::SHARED_LIBRARY: - return "_CREATE_SHARED_LIBRARY"; + return "CMAKE_" + lang + "_CREATE_SHARED_LIBRARY"; case cmTarget::MODULE_LIBRARY: - return "_CREATE_SHARED_MODULE"; + return "CMAKE_" + lang + "_CREATE_SHARED_MODULE"; case cmTarget::EXECUTABLE: - return "_LINK_EXECUTABLE"; + return "CMAKE_" + lang + "_LINK_EXECUTABLE"; default: break; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9d13e6c..29aa410 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -75,9 +75,9 @@ public: void GetAppleArchs(const std::string& config, std::vector& archVec) const; - ///! Return the rule variable used to create this type of target, - // need to add CMAKE_(LANG) for full name. - const char* GetCreateRuleVariable() const; + /** Return the rule variable used to create this type of target. */ + std::string GetCreateRuleVariable(std::string const& lang, + std::string const& config) const; /** Get the include directories for this target. */ std::vector GetIncludeDirectories( diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index a6ad714..dac95ff 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -657,10 +657,10 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang, { std::string objs; std::vector objVector; + std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); // Add all the sources outputs to the depends of the target std::vector classes; - target.GetSourceFiles(classes, - this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); + target.GetSourceFiles(classes, config); for(std::vector::const_iterator i = classes.begin(); i != classes.end(); ++i) { @@ -686,9 +686,7 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang, } } } - std::string createRule = "CMAKE_"; - createRule += llang; - createRule += target.GetCreateRuleVariable(); + std::string createRule = target.GetCreateRuleVariable(llang, config); bool useWatcomQuote = this->Makefile->IsOn(createRule+"_USE_WATCOM_QUOTE"); std::string targetName = target.Target->GetFullName(); // Executable : diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index b467d22..cfcf9f4 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -314,9 +314,8 @@ cmNinjaNormalTargetGenerator std::vector linkCmds; cmMakefile* mf = this->GetMakefile(); { - std::string linkCmdVar = "CMAKE_"; - linkCmdVar += this->TargetLinkLanguage; - linkCmdVar += this->GetGeneratorTarget()->GetCreateRuleVariable(); + std::string linkCmdVar = this->GetGeneratorTarget() + ->GetCreateRuleVariable(this->TargetLinkLanguage, this->GetConfigName()); const char *linkCmd = mf->GetDefinition(linkCmdVar); if (linkCmd) { @@ -451,8 +450,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() std::string linkPath; cmGeneratorTarget& genTarget = *this->GetGeneratorTarget(); - std::string createRule = "CMAKE_"; - createRule += this->TargetLinkLanguage + genTarget.GetCreateRuleVariable(); + std::string createRule = + genTarget.GetCreateRuleVariable(this->TargetLinkLanguage, + this->GetConfigName()); bool useWatcomQuote = mf->IsOn(createRule+"_USE_WATCOM_QUOTE"); cmLocalNinjaGenerator& localGen = *this->GetLocalGenerator(); localGen.GetTargetFlags(vars["LINK_LIBRARIES"], -- cgit v0.12