diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2021-03-30 10:13:33 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2021-03-30 13:04:03 (GMT) |
commit | 1b346350af4cc1b2d66c03b76ced8226724399fd (patch) | |
tree | 5aa0cdb4178147f3b52f8866498819f377f06b98 /Source | |
parent | d212d91f14d2f2ed4f77ea7f190bbea2a4f6e302 (diff) | |
download | CMake-1b346350af4cc1b2d66c03b76ced8226724399fd.zip CMake-1b346350af4cc1b2d66c03b76ced8226724399fd.tar.gz CMake-1b346350af4cc1b2d66c03b76ced8226724399fd.tar.bz2 |
Makefiles dependencies: normalize windows paths
Fixes: #21997
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGccDepfileLexerHelper.cxx | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Source/cmGccDepfileLexerHelper.cxx b/Source/cmGccDepfileLexerHelper.cxx index c782bcd..afa8e9b 100644 --- a/Source/cmGccDepfileLexerHelper.cxx +++ b/Source/cmGccDepfileLexerHelper.cxx @@ -12,6 +12,8 @@ #include "LexerParser/cmGccDepfileLexer.h" #ifdef _WIN32 +# include <cctype> + # include "cmsys/Encoding.h" #endif @@ -123,11 +125,21 @@ void cmGccDepfileLexerHelper::sanitizeContent() if (it->rules.empty()) { it = this->Content.erase(it); } else { - // Remove empty paths + // 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; } } |