diff options
author | Brad King <brad.king@kitware.com> | 2021-05-28 19:28:25 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-05-28 19:41:38 (GMT) |
commit | 316cbbe8d570775eb08683a72808ee07bddcd3e0 (patch) | |
tree | f4ef2146549fbb10751807e4d0422c36c83f27af /Source/cmMakefileTargetGenerator.cxx | |
parent | f4f80cfec6ba4667a2efce8c88d1e3d23f053cdc (diff) | |
download | CMake-316cbbe8d570775eb08683a72808ee07bddcd3e0.zip CMake-316cbbe8d570775eb08683a72808ee07bddcd3e0.tar.gz CMake-316cbbe8d570775eb08683a72808ee07bddcd3e0.tar.bz2 |
Makefiles: Fix CMAKE_EXPORT_COMPILE_COMMANDS crash with custom compile rule
Extend the fix from commit 67e2130c96 (Makefiles: Fix
CMAKE_EXPORT_COMPILE_COMMANDS crash with custom compile rule,
2020-11-20, v3.19.1~8^2) to work for the `<FLAGS>` placeholder too.
Also fix the test case to actually enable `EXPORT_COMPILE_COMMANDS`
on the test target.
Fixes: #22261
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 4918bf6..5f7f3dc 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) { |