summaryrefslogtreecommitdiff
path: root/Source/cmMakefileTargetGenerator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmMakefileTargetGenerator.cxx')
-rw-r--r--Source/cmMakefileTargetGenerator.cxx7
1 files changed, 5 insertions, 2 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 4918bf676..5f7f3dc5b 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -926,8 +926,11 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
compileCommand, vars);
std::string workingDirectory =
this->LocalGenerator->GetCurrentBinaryDirectory();
- compileCommand.replace(compileCommand.find(langFlags), langFlags.size(),
- this->GetFlags(lang, this->GetConfigName()));
+ std::string::size_type lfPos = compileCommand.find(langFlags);
+ if (lfPos != std::string::npos) {
+ compileCommand.replace(lfPos, langFlags.size(),
+ this->GetFlags(lang, this->GetConfigName()));
+ }
std::string langDefines = std::string("$(") + lang + "_DEFINES)";
std::string::size_type ldPos = compileCommand.find(langDefines);
if (ldPos != std::string::npos) {