Xcode: Honor -g0 to disable debugging (#12377)
This commit changes ExtractFlag to remove all occurences of a flag, and only save the last one. (i.e., the dominant one according to GCC rules)
This commit is contained in:
parent
48ba9b2f19
commit
cb22afc02c
|
@ -1219,20 +1219,31 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases,
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
// This function removes each occurence of the flag and returns the last one
|
||||||
|
// (i.e., the dominant flag in GCC)
|
||||||
std::string cmGlobalXCodeGenerator::ExtractFlag(const char* flag,
|
std::string cmGlobalXCodeGenerator::ExtractFlag(const char* flag,
|
||||||
std::string& flags)
|
std::string& flags)
|
||||||
{
|
{
|
||||||
std::string retFlag;
|
std::string retFlag;
|
||||||
std::string::size_type pos = flags.find(flag);
|
std::string::size_type pos = flags.rfind(flag);
|
||||||
if(pos != flags.npos && (pos ==0 || flags[pos-1]==' '))
|
bool saved = false;
|
||||||
|
while(pos != flags.npos)
|
||||||
|
{
|
||||||
|
if(pos == 0 || flags[pos-1]==' ')
|
||||||
{
|
{
|
||||||
while(pos < flags.size() && flags[pos] != ' ')
|
while(pos < flags.size() && flags[pos] != ' ')
|
||||||
|
{
|
||||||
|
if(!saved)
|
||||||
{
|
{
|
||||||
retFlag += flags[pos];
|
retFlag += flags[pos];
|
||||||
|
}
|
||||||
flags[pos] = ' ';
|
flags[pos] = ' ';
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
saved = true;
|
||||||
|
pos = flags.rfind(flag);
|
||||||
|
}
|
||||||
return retFlag;
|
return retFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1870,7 +1881,17 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
|
||||||
flags += gflag;
|
flags += gflag;
|
||||||
}
|
}
|
||||||
const char* debugStr = "YES";
|
const char* debugStr = "YES";
|
||||||
if(gflagc.size() ==0 && gflag.size() == 0)
|
// We can't set the Xcode flag differently depending on the language,
|
||||||
|
// so put them back in this case.
|
||||||
|
if( (lang && strcmp(lang, "CXX") == 0) && gflag != gflagc )
|
||||||
|
{
|
||||||
|
cflags += " ";
|
||||||
|
cflags += gflagc;
|
||||||
|
flags += " ";
|
||||||
|
flags += gflag;
|
||||||
|
debugStr = "NO";
|
||||||
|
}
|
||||||
|
if( gflag == "-g0" || gflag.size() == 0 )
|
||||||
{
|
{
|
||||||
debugStr = "NO";
|
debugStr = "NO";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue