summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalXCodeGenerator.cxx
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2011-09-07 19:39:15 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2011-09-07 19:39:15 (GMT)
commitfde0a4ddd104be279600f3a80521169708a84875 (patch)
treedcd3780b6fe2c2bec0acd7e885871650fe04a862 /Source/cmGlobalXCodeGenerator.cxx
parent1a5c99581eddd677ba30653d0cb68161a4e0cb8f (diff)
parentcb22afc02c0524ff2b701b33a29339dde1e80bbd (diff)
downloadCMake-fde0a4ddd104be279600f3a80521169708a84875.zip
CMake-fde0a4ddd104be279600f3a80521169708a84875.tar.gz
CMake-fde0a4ddd104be279600f3a80521169708a84875.tar.bz2
Merge topic 'fix-12377-xcode-honor-g0'
cb22afc Xcode: Honor -g0 to disable debugging (#12377)
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 98a08a9..09265ae 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -1229,19 +1229,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;
}
@@ -1880,7 +1891,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";
}