diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index ec5ce9e93..153c611de 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -943,18 +943,32 @@ void cmGeneratorTarget::GetAppleArchs(const std::string& config, } //---------------------------------------------------------------------------- -const char* cmGeneratorTarget::GetCreateRuleVariable() const +std::string +cmGeneratorTarget::GetCreateRuleVariable(std::string const& lang, + std::string const& config) const { switch(this->GetType()) { case cmTarget::STATIC_LIBRARY: - return "_CREATE_STATIC_LIBRARY"; + { + std::string var = "CMAKE_" + lang + "_CREATE_STATIC_LIBRARY"; + if(this->Target->GetFeatureAsBool( + "INTERPROCEDURAL_OPTIMIZATION", config)) + { + std::string varIPO = var + "_IPO"; + if(this->Makefile->GetDefinition(varIPO)) + { + return varIPO; + } + } + return var; + } 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 9d13e6c0b..29aa4106f 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 5d58265b0..e80b8eee1 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/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 73d24a929..a08d731b2 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -2105,7 +2105,7 @@ const char* cmMakefileTargetGenerator::GetFeature(const std::string& feature) //---------------------------------------------------------------------------- bool cmMakefileTargetGenerator::GetFeatureAsBool(const std::string& feature) { - return cmSystemTools::IsOn(this->GetFeature(feature)); + return this->Target->GetFeatureAsBool(feature, this->ConfigName); } //---------------------------------------------------------------------------- diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index b467d22ad..cfcf9f47b 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"], diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 54e398c6b..c3b4c7581 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -105,7 +105,7 @@ const char* cmNinjaTargetGenerator::GetFeature(const std::string& feature) // TODO: Picked up from cmMakefileTargetGenerator. Refactor it. bool cmNinjaTargetGenerator::GetFeatureAsBool(const std::string& feature) { - return cmSystemTools::IsOn(this->GetFeature(feature)); + return this->Target->GetFeatureAsBool(feature, this->GetConfigName()); } // TODO: Picked up from cmMakefileTargetGenerator. Refactor it. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a961ddc19..15acfdd5c 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3181,6 +3181,13 @@ const char* cmTarget::GetFeature(const std::string& feature, return this->Makefile->GetFeature(feature, config); } +//---------------------------------------------------------------------------- +bool cmTarget::GetFeatureAsBool(const std::string& feature, + const std::string& config) const +{ + return cmSystemTools::IsOn(this->GetFeature(feature, config)); +} + //---------------------------------------------------------------------------- bool cmTarget::HandleLocationPropertyPolicy(cmMakefile* context) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 45d1bd6c2..2d51835e3 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -237,6 +237,8 @@ public: const char* GetFeature(const std::string& feature, const std::string& config) const; + bool GetFeatureAsBool(const std::string& feature, + const std::string& config) const; bool IsImported() const {return this->IsImportedTarget;}