diff options
author | Brad King <brad.king@kitware.com> | 2021-05-29 13:45:27 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-05-29 13:45:33 (GMT) |
commit | 37cda77d1614fc07a81fcb96783108441a77df1b (patch) | |
tree | b7c03ca925f4af94847045601687c5ab9b6c18ec /Source/cmMakefileTargetGenerator.cxx | |
parent | 7676e11943a6446e3cdc60370a37e4ce9cc548d3 (diff) | |
parent | 316cbbe8d570775eb08683a72808ee07bddcd3e0 (diff) | |
download | CMake-37cda77d1614fc07a81fcb96783108441a77df1b.zip CMake-37cda77d1614fc07a81fcb96783108441a77df1b.tar.gz CMake-37cda77d1614fc07a81fcb96783108441a77df1b.tar.bz2 |
Merge topic 'fix-compile-db-crash'
316cbbe8d5 Makefiles: Fix CMAKE_EXPORT_COMPILE_COMMANDS crash with custom compile rule
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6173
Diffstat (limited to 'Source/cmMakefileTargetGenerator.cxx')
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 4542672..e87f81b 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -909,8 +909,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) { |