summaryrefslogtreecommitdiff
path: root/Source/cmGccDepfileLexerHelper.cxx
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2022-01-16 14:04:05 +0100
committerMarc Chevrier <marc.chevrier@gmail.com>2022-01-16 16:21:12 +0100
commit0b65a2b2531b05abe1bc1f1950bb963af7a6d42f (patch)
treef030499394a3dd427ff56f1d30424307254ef705 /Source/cmGccDepfileLexerHelper.cxx
parente04a352cca523eba2ac0d60063a3799f5bb1c69e (diff)
downloadcmake-0b65a2b2531b05abe1bc1f1950bb963af7a6d42f.tar.gz
add_custom_command(DEPFILE): ensure all dependencies are taken into account
Diffstat (limited to 'Source/cmGccDepfileLexerHelper.cxx')
-rw-r--r--Source/cmGccDepfileLexerHelper.cxx40
1 files changed, 20 insertions, 20 deletions
diff --git a/Source/cmGccDepfileLexerHelper.cxx b/Source/cmGccDepfileLexerHelper.cxx
index afa8e9b26f..34c88248a0 100644
--- a/Source/cmGccDepfileLexerHelper.cxx
+++ b/Source/cmGccDepfileLexerHelper.cxx
@@ -113,6 +113,24 @@ void cmGccDepfileLexerHelper::addToCurrentPath(const char* s)
void cmGccDepfileLexerHelper::sanitizeContent()
{
for (auto it = this->Content.begin(); it != this->Content.end();) {
+ // Remove empty paths and normalize windows paths
+ for (auto pit = it->paths.begin(); pit != it->paths.end();) {
+ if (pit->empty()) {
+ pit = it->paths.erase(pit);
+ } else {
+#if defined(_WIN32)
+ // Unescape the colon following the drive letter.
+ // Some versions of GNU compilers can escape this character.
+ // c\:\path must be transformed to c:\path
+ if (pit->size() >= 3 && std::toupper((*pit)[0]) >= 'A' &&
+ std::toupper((*pit)[0]) <= 'Z' && (*pit)[1] == '\\' &&
+ (*pit)[2] == ':') {
+ pit->erase(1, 1);
+ }
+#endif
+ ++pit;
+ }
+ }
// Remove empty rules
for (auto rit = it->rules.begin(); rit != it->rules.end();) {
if (rit->empty()) {
@@ -121,28 +139,10 @@ void cmGccDepfileLexerHelper::sanitizeContent()
++rit;
}
}
- // Remove the entry if rules are empty
- if (it->rules.empty()) {
+ // Remove the entry if rules are empty or do not have any paths
+ if (it->rules.empty() || it->paths.empty()) {
it = this->Content.erase(it);
} else {
- // Remove empty paths and normalize windows paths
- for (auto pit = it->paths.begin(); pit != it->paths.end();) {
- if (pit->empty()) {
- pit = it->paths.erase(pit);
- } else {
-#if defined(_WIN32)
- // Unescape the colon following the drive letter.
- // Some versions of GNU compilers can escape this character.
- // c\:\path must be transformed to c:\path
- if (pit->size() >= 3 && std::toupper((*pit)[0]) >= 'A' &&
- std::toupper((*pit)[0]) <= 'Z' && (*pit)[1] == '\\' &&
- (*pit)[2] == ':') {
- pit->erase(1, 1);
- }
-#endif
- ++pit;
- }
- }
++it;
}
}