summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalXCodeGenerator.cxx
diff options
context:
space:
mode:
authorJohan Bjork <phb@spotify.com>2011-08-18 17:30:51 (GMT)
committerDavid Cole <david.cole@kitware.com>2011-09-06 19:04:58 (GMT)
commitcb22afc02c0524ff2b701b33a29339dde1e80bbd (patch)
treeb2555cdf7ad4a558614e86cabb947871b238f657 /Source/cmGlobalXCodeGenerator.cxx
parent48ba9b2f197cde7f309b9ef3770e1bf003a7e8e8 (diff)
downloadCMake-cb22afc02c0524ff2b701b33a29339dde1e80bbd.zip
CMake-cb22afc02c0524ff2b701b33a29339dde1e80bbd.tar.gz
CMake-cb22afc02c0524ff2b701b33a29339dde1e80bbd.tar.bz2
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)
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx35
1 files changed, 28 insertions, 7 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 02a95fe..a8a6eb4 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -1219,19 +1219,30 @@ 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& flags)
{
std::string retFlag;
- std::string::size_type pos = flags.find(flag);
- if(pos != flags.npos && (pos ==0 || flags[pos-1]==' '))
+ std::string::size_type pos = flags.rfind(flag);
+ bool saved = false;
+ while(pos != flags.npos)
{
- while(pos < flags.size() && flags[pos] != ' ')
+ if(pos == 0 || flags[pos-1]==' ')
{
- retFlag += flags[pos];
- flags[pos] = ' ';
- pos++;
+ while(pos < flags.size() && flags[pos] != ' ')
+ {
+ if(!saved)
+ {
+ retFlag += flags[pos];
+ }
+ flags[pos] = ' ';
+ pos++;
+ }
}
+ saved = true;
+ pos = flags.rfind(flag);
}
return retFlag;
}
@@ -1870,7 +1881,17 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
flags += gflag;
}
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";
}