diff options
author | Brad King <brad.king@kitware.com> | 2020-11-20 14:45:14 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-11-20 14:45:14 (GMT) |
commit | 67e2130c963bb3d9d437f00f5d6b8e95d2f5fb18 (patch) | |
tree | 56c0932de6d8ab4f49ae293a9a73bda85e7a3c87 /Source/cmMakefileTargetGenerator.cxx | |
parent | 1d1d78bbe1ed7113927fd0dd078741de3c722b14 (diff) | |
download | CMake-67e2130c963bb3d9d437f00f5d6b8e95d2f5fb18.zip CMake-67e2130c963bb3d9d437f00f5d6b8e95d2f5fb18.tar.gz CMake-67e2130c963bb3d9d437f00f5d6b8e95d2f5fb18.tar.bz2 |
Makefiles: Fix CMAKE_EXPORT_COMPILE_COMMANDS crash with custom compile rule
Fixes: #21471
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 5f97d86..6e6c8df 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -838,13 +838,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"), |