ENH: only replace the language being used in expand rule variables
This commit is contained in:
parent
d11cecab7d
commit
a7e20abcdb
|
@ -996,6 +996,7 @@ static const char* ruleReplaceVars[] =
|
||||||
|
|
||||||
void
|
void
|
||||||
cmLocalUnixMakefileGenerator::ExpandRuleVariables(std::string& s,
|
cmLocalUnixMakefileGenerator::ExpandRuleVariables(std::string& s,
|
||||||
|
const char* lang,
|
||||||
const char* objects,
|
const char* objects,
|
||||||
const char* target,
|
const char* target,
|
||||||
const char* linkLibs,
|
const char* linkLibs,
|
||||||
|
@ -1065,11 +1066,19 @@ cmLocalUnixMakefileGenerator::ExpandRuleVariables(std::string& s,
|
||||||
}
|
}
|
||||||
if(targetSOName)
|
if(targetSOName)
|
||||||
{
|
{
|
||||||
if(m_Makefile->GetDefinition("CMAKE_SHARED_LIBRARY_SONAME_C_FLAG"))
|
bool replaced = false;
|
||||||
|
if(lang)
|
||||||
{
|
{
|
||||||
cmSystemTools::ReplaceString(s, "<TARGET_SONAME>", targetSOName);
|
std::string name = "CMAKE_SHARED_LIBRARY_SONAME_";
|
||||||
|
name += lang;
|
||||||
|
name += "_FLAG";
|
||||||
|
if(m_Makefile->GetDefinition(name.c_str()))
|
||||||
|
{
|
||||||
|
replaced = true;
|
||||||
|
cmSystemTools::ReplaceString(s, "<TARGET_SONAME>", targetSOName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
if(!replaced)
|
||||||
{
|
{
|
||||||
cmSystemTools::ReplaceString(s, "<TARGET_SONAME>", "");
|
cmSystemTools::ReplaceString(s, "<TARGET_SONAME>", "");
|
||||||
}
|
}
|
||||||
|
@ -1083,29 +1092,32 @@ cmLocalUnixMakefileGenerator::ExpandRuleVariables(std::string& s,
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
while(ruleReplaceVars[pos])
|
while(ruleReplaceVars[pos])
|
||||||
{
|
{
|
||||||
std::string replace = "<";
|
if(lang)
|
||||||
replace += ruleReplaceVars[pos];
|
|
||||||
replace += ">";
|
|
||||||
std::string replaceWith = ruleReplaceVars[pos];
|
|
||||||
for(std::vector<std::string>::iterator i = enabledLanguages.begin();
|
|
||||||
i != enabledLanguages.end(); ++i)
|
|
||||||
{
|
{
|
||||||
|
std::string replace = "<";
|
||||||
|
replace += ruleReplaceVars[pos];
|
||||||
|
replace += ">";
|
||||||
|
std::string replaceWith = ruleReplaceVars[pos];
|
||||||
std::string actualReplace = replace;
|
std::string actualReplace = replace;
|
||||||
cmSystemTools::ReplaceString(actualReplace, "${LANG}", i->c_str());
|
cmSystemTools::ReplaceString(actualReplace, "${LANG}", lang);
|
||||||
std::string actualReplaceWith = replaceWith;
|
std::string actualReplaceWith = replaceWith;
|
||||||
cmSystemTools::ReplaceString(actualReplaceWith, "${LANG}", i->c_str());
|
cmSystemTools::ReplaceString(actualReplaceWith, "${LANG}", lang);
|
||||||
replace = m_Makefile->GetSafeDefinition(actualReplaceWith.c_str());
|
replace = m_Makefile->GetSafeDefinition(actualReplaceWith.c_str());
|
||||||
// if the variable is not a FLAG then treat it like a path
|
// if the variable is not a FLAG then treat it like a path
|
||||||
if(actualReplaceWith.find("_FLAG") == actualReplaceWith.npos)
|
if(actualReplaceWith.find("_FLAG") == actualReplaceWith.npos)
|
||||||
{
|
{
|
||||||
replace = this->ConvertToOutputForExisting(replace.c_str());
|
replace = this->ConvertToOutputForExisting(replace.c_str());
|
||||||
}
|
}
|
||||||
cmSystemTools::ReplaceString(s, actualReplace.c_str(), replace.c_str());
|
if(actualReplace.size())
|
||||||
|
{
|
||||||
|
cmSystemTools::ReplaceString(s, actualReplace.c_str(), replace.c_str());
|
||||||
|
}
|
||||||
|
pos++;
|
||||||
}
|
}
|
||||||
pos++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cmLocalUnixMakefileGenerator::OutputLibraryRule(std::ostream& fout,
|
void cmLocalUnixMakefileGenerator::OutputLibraryRule(std::ostream& fout,
|
||||||
const char* name,
|
const char* name,
|
||||||
|
@ -1238,6 +1250,7 @@ void cmLocalUnixMakefileGenerator::OutputLibraryRule(std::ostream& fout,
|
||||||
i != commands.end(); ++i)
|
i != commands.end(); ++i)
|
||||||
{
|
{
|
||||||
this->ExpandRuleVariables(*i,
|
this->ExpandRuleVariables(*i,
|
||||||
|
t.GetLinkerLanguage(m_GlobalGenerator),
|
||||||
objs.c_str(),
|
objs.c_str(),
|
||||||
targetFullPathReal.c_str(),
|
targetFullPathReal.c_str(),
|
||||||
linklibs.str().c_str(),
|
linklibs.str().c_str(),
|
||||||
|
@ -1502,6 +1515,7 @@ void cmLocalUnixMakefileGenerator::OutputExecutableRule(std::ostream& fout,
|
||||||
i != commands.end(); ++i)
|
i != commands.end(); ++i)
|
||||||
{
|
{
|
||||||
this->ExpandRuleVariables(*i,
|
this->ExpandRuleVariables(*i,
|
||||||
|
linkLanguage,
|
||||||
objs.c_str(),
|
objs.c_str(),
|
||||||
target.c_str(),
|
target.c_str(),
|
||||||
linklibs.str().c_str(),
|
linklibs.str().c_str(),
|
||||||
|
@ -2897,6 +2911,7 @@ OutputBuildObjectFromSource(std::ostream& fout,
|
||||||
i != commands.end(); ++i)
|
i != commands.end(); ++i)
|
||||||
{
|
{
|
||||||
this->ExpandRuleVariables(*i,
|
this->ExpandRuleVariables(*i,
|
||||||
|
lang,
|
||||||
0, // no objects
|
0, // no objects
|
||||||
0, // no target
|
0, // no target
|
||||||
0, // no link libs
|
0, // no link libs
|
||||||
|
|
|
@ -104,6 +104,7 @@ protected:
|
||||||
const char* linkFlags
|
const char* linkFlags
|
||||||
);
|
);
|
||||||
void ExpandRuleVariables(std::string& string,
|
void ExpandRuleVariables(std::string& string,
|
||||||
|
const char* language,
|
||||||
const char* objects=0,
|
const char* objects=0,
|
||||||
const char* target=0,
|
const char* target=0,
|
||||||
const char* linkLibs=0,
|
const char* linkLibs=0,
|
||||||
|
|
Loading…
Reference in New Issue