diff options
author | Brad King <brad.king@kitware.com> | 2020-11-23 16:19:47 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-11-23 16:19:59 (GMT) |
commit | c178fad186e27e37abfac7f477c0e84ab7fe71d8 (patch) | |
tree | 8d80d48c8e066023e2bd621666b955f9ae7fcd12 /Source/cmMakefileTargetGenerator.cxx | |
parent | 732cc384593385ae95c6422ffa8e842a8b70f0e8 (diff) | |
parent | 67e2130c963bb3d9d437f00f5d6b8e95d2f5fb18 (diff) | |
download | CMake-c178fad186e27e37abfac7f477c0e84ab7fe71d8.zip CMake-c178fad186e27e37abfac7f477c0e84ab7fe71d8.tar.gz CMake-c178fad186e27e37abfac7f477c0e84ab7fe71d8.tar.bz2 |
Merge topic 'fix-compile-db-crash'
67e2130c96 Makefiles: Fix CMAKE_EXPORT_COMPILE_COMMANDS crash with custom compile rule
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5521
Diffstat (limited to 'Source/cmMakefileTargetGenerator.cxx')
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index f0d464e..71660a0 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -831,13 +831,17 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( compileCommand.replace(compileCommand.find(langFlags), langFlags.size(), this->GetFlags(lang, this->GetConfigName())); std::string langDefines = std::string("$(") + lang + "_DEFINES)"; - compileCommand.replace(compileCommand.find(langDefines), - langDefines.size(), - this->GetDefines(lang, this->GetConfigName())); + std::string::size_type ldPos = compileCommand.find(langDefines); + if (ldPos != std::string::npos) { + compileCommand.replace(ldPos, langDefines.size(), + this->GetDefines(lang, this->GetConfigName())); + } std::string langIncludes = std::string("$(") + lang + "_INCLUDES)"; - compileCommand.replace(compileCommand.find(langIncludes), - langIncludes.size(), - this->GetIncludes(lang, this->GetConfigName())); + std::string::size_type liPos = compileCommand.find(langIncludes); + if (liPos != std::string::npos) { + compileCommand.replace(liPos, langIncludes.size(), + this->GetIncludes(lang, this->GetConfigName())); + } cmProp eliminate[] = { this->Makefile->GetDefinition("CMAKE_START_TEMP_FILE"), |