Merge topic 'ninja-intel-ipo'

b6e2e0d1 Ninja: Fix Intel interprocedural optimization with static libraries
5d12b87b cmGeneratorTarget: Improve GetCreateRuleVariable API
c2eeb08b cmTarget: Add GetFeatureAsBool method
This commit is contained in:
Brad King 2014-05-22 10:37:50 -04:00 committed by CMake Topic Stage
commit 3ea9bde845
8 changed files with 41 additions and 20 deletions

View File

@ -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()) switch(this->GetType())
{ {
case cmTarget::STATIC_LIBRARY: 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: case cmTarget::SHARED_LIBRARY:
return "_CREATE_SHARED_LIBRARY"; return "CMAKE_" + lang + "_CREATE_SHARED_LIBRARY";
case cmTarget::MODULE_LIBRARY: case cmTarget::MODULE_LIBRARY:
return "_CREATE_SHARED_MODULE"; return "CMAKE_" + lang + "_CREATE_SHARED_MODULE";
case cmTarget::EXECUTABLE: case cmTarget::EXECUTABLE:
return "_LINK_EXECUTABLE"; return "CMAKE_" + lang + "_LINK_EXECUTABLE";
default: default:
break; break;
} }

View File

@ -75,9 +75,9 @@ public:
void GetAppleArchs(const std::string& config, void GetAppleArchs(const std::string& config,
std::vector<std::string>& archVec) const; std::vector<std::string>& archVec) const;
///! 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. std::string GetCreateRuleVariable(std::string const& lang,
const char* GetCreateRuleVariable() const; std::string const& config) const;
/** Get the include directories for this target. */ /** Get the include directories for this target. */
std::vector<std::string> GetIncludeDirectories( std::vector<std::string> GetIncludeDirectories(

View File

@ -657,10 +657,10 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang,
{ {
std::string objs; std::string objs;
std::vector<std::string> objVector; std::vector<std::string> objVector;
std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
// Add all the sources outputs to the depends of the target // Add all the sources outputs to the depends of the target
std::vector<cmSourceFile*> classes; std::vector<cmSourceFile*> classes;
target.GetSourceFiles(classes, target.GetSourceFiles(classes, config);
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin(); for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
i != classes.end(); ++i) i != classes.end(); ++i)
{ {
@ -686,9 +686,7 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang,
} }
} }
} }
std::string createRule = "CMAKE_"; std::string createRule = target.GetCreateRuleVariable(llang, config);
createRule += llang;
createRule += target.GetCreateRuleVariable();
bool useWatcomQuote = this->Makefile->IsOn(createRule+"_USE_WATCOM_QUOTE"); bool useWatcomQuote = this->Makefile->IsOn(createRule+"_USE_WATCOM_QUOTE");
std::string targetName = target.Target->GetFullName(); std::string targetName = target.Target->GetFullName();
// Executable : // Executable :

View File

@ -2105,7 +2105,7 @@ const char* cmMakefileTargetGenerator::GetFeature(const std::string& feature)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmMakefileTargetGenerator::GetFeatureAsBool(const std::string& feature) bool cmMakefileTargetGenerator::GetFeatureAsBool(const std::string& feature)
{ {
return cmSystemTools::IsOn(this->GetFeature(feature)); return this->Target->GetFeatureAsBool(feature, this->ConfigName);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -314,9 +314,8 @@ cmNinjaNormalTargetGenerator
std::vector<std::string> linkCmds; std::vector<std::string> linkCmds;
cmMakefile* mf = this->GetMakefile(); cmMakefile* mf = this->GetMakefile();
{ {
std::string linkCmdVar = "CMAKE_"; std::string linkCmdVar = this->GetGeneratorTarget()
linkCmdVar += this->TargetLinkLanguage; ->GetCreateRuleVariable(this->TargetLinkLanguage, this->GetConfigName());
linkCmdVar += this->GetGeneratorTarget()->GetCreateRuleVariable();
const char *linkCmd = mf->GetDefinition(linkCmdVar); const char *linkCmd = mf->GetDefinition(linkCmdVar);
if (linkCmd) if (linkCmd)
{ {
@ -451,8 +450,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
std::string linkPath; std::string linkPath;
cmGeneratorTarget& genTarget = *this->GetGeneratorTarget(); cmGeneratorTarget& genTarget = *this->GetGeneratorTarget();
std::string createRule = "CMAKE_"; std::string createRule =
createRule += this->TargetLinkLanguage + genTarget.GetCreateRuleVariable(); genTarget.GetCreateRuleVariable(this->TargetLinkLanguage,
this->GetConfigName());
bool useWatcomQuote = mf->IsOn(createRule+"_USE_WATCOM_QUOTE"); bool useWatcomQuote = mf->IsOn(createRule+"_USE_WATCOM_QUOTE");
cmLocalNinjaGenerator& localGen = *this->GetLocalGenerator(); cmLocalNinjaGenerator& localGen = *this->GetLocalGenerator();
localGen.GetTargetFlags(vars["LINK_LIBRARIES"], localGen.GetTargetFlags(vars["LINK_LIBRARIES"],

View File

@ -105,7 +105,7 @@ const char* cmNinjaTargetGenerator::GetFeature(const std::string& feature)
// TODO: Picked up from cmMakefileTargetGenerator. Refactor it. // TODO: Picked up from cmMakefileTargetGenerator. Refactor it.
bool cmNinjaTargetGenerator::GetFeatureAsBool(const std::string& feature) 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. // TODO: Picked up from cmMakefileTargetGenerator. Refactor it.

View File

@ -3181,6 +3181,13 @@ const char* cmTarget::GetFeature(const std::string& feature,
return this->Makefile->GetFeature(feature, config); 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 bool cmTarget::HandleLocationPropertyPolicy(cmMakefile* context) const
{ {

View File

@ -237,6 +237,8 @@ public:
const char* GetFeature(const std::string& feature, const char* GetFeature(const std::string& feature,
const std::string& config) const; const std::string& config) const;
bool GetFeatureAsBool(const std::string& feature,
const std::string& config) const;
bool IsImported() const {return this->IsImportedTarget;} bool IsImported() const {return this->IsImportedTarget;}