diff options
author | Brad King <brad.king@kitware.com> | 2013-11-19 14:46:59 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2013-11-19 14:46:59 (GMT) |
commit | e752a02368cec9fa169e1b0cea1df065d8fe55d6 (patch) | |
tree | 3f8384d404cc74119f5d6b505a53f028389f1bfa | |
parent | 4bb41b30d6b84bbf8dd82f06a717a510308fa28c (diff) | |
parent | 3a8f34b98cbbe8001f1645516701623a78504611 (diff) | |
download | CMake-e752a02368cec9fa169e1b0cea1df065d8fe55d6.zip CMake-e752a02368cec9fa169e1b0cea1df065d8fe55d6.tar.gz CMake-e752a02368cec9fa169e1b0cea1df065d8fe55d6.tar.bz2 |
Merge topic 'fix-remove-forbidden-flags'
3a8f34b Makefile: Remove "forbidden" flags only as a whole
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 6770e10..2fcad79 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -27,6 +27,7 @@ #include "cmMakefileLibraryTargetGenerator.h" #include "cmMakefileUtilityTargetGenerator.h" +#include <ctype.h> cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmTarget* target) : OSXBundleGenerator(0) @@ -1694,10 +1695,42 @@ void cmMakefileTargetGenerator::RemoveForbiddenFlags(const char* flagVar, this->Makefile->GetSafeDefinition(removeFlags.c_str()); std::vector<std::string> removeList; cmSystemTools::ExpandListArgument(removeflags, removeList); + for(std::vector<std::string>::iterator i = removeList.begin(); i != removeList.end(); ++i) { - cmSystemTools::ReplaceString(linkFlags, i->c_str(), ""); + std::string tmp; + std::string::size_type lastPosition = 0; + + for(;;) + { + std::string::size_type position = linkFlags.find(*i, lastPosition); + + if(position == std::string::npos) + { + tmp += linkFlags.substr(lastPosition); + break; + } + else + { + std::string::size_type prefixLength = position - lastPosition; + tmp += linkFlags.substr(lastPosition, prefixLength); + lastPosition = position + i->length(); + + bool validFlagStart = position == 0 || + isspace(linkFlags[position - 1]); + + bool validFlagEnd = lastPosition == linkFlags.size() || + isspace(linkFlags[lastPosition]); + + if(!validFlagStart || !validFlagEnd) + { + tmp += *i; + } + } + } + + linkFlags = tmp; } } |