diff options
author | Brad King <brad.king@kitware.com> | 2015-04-03 15:15:12 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-04-03 17:04:57 (GMT) |
commit | af924827120f39f1a7a940bc3f6bc487665145d9 (patch) | |
tree | cc0512810a6bbc3f79c5fc179ce151c20bcbaaec /Source | |
parent | e46224a7cdbcbbfce63f21096bf2b4a5f01c3c13 (diff) | |
download | CMake-af924827120f39f1a7a940bc3f6bc487665145d9.zip CMake-af924827120f39f1a7a940bc3f6bc487665145d9.tar.gz CMake-af924827120f39f1a7a940bc3f6bc487665145d9.tar.bz2 |
Makefile: Tolerate a BOM while scanning source dependencies (#15493)
Otherwise an #include directive on the first line of a source file is
ignored if the file contains a Byte-Order-Mark.
Suggested-by: Aleksey Konovalov <konovalov.aleks@gmail.com>
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmDependsC.cxx | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index 63d8fa6..6cdd4c1 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -242,13 +242,22 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources, cmsys::ifstream fin(fullName.c_str()); if(fin) { - // Add this file as a dependency. - dependencies.insert(fullName); + cmsys::FStream::BOM bom = cmsys::FStream::ReadBOM(fin); + if(bom == cmsys::FStream::BOM_None || + bom == cmsys::FStream::BOM_UTF8) + { + // Add this file as a dependency. + dependencies.insert(fullName); - // Scan this file for new dependencies. Pass the directory - // containing the file to handle double-quote includes. - std::string dir = cmSystemTools::GetFilenamePath(fullName); - this->Scan(fin, dir.c_str(), fullName); + // Scan this file for new dependencies. Pass the directory + // containing the file to handle double-quote includes. + std::string dir = cmSystemTools::GetFilenamePath(fullName); + this->Scan(fin, dir.c_str(), fullName); + } + else + { + // Skip file with encoding we do not implement. + } } } } |